Jekyll on FreeBSD
As I’ve mentioned, this website is statically generated by Jekyll, a Ruby based static site generator. My needs are very simple, so I have a git based workflow, where the site contents are version controlled in the form of a directory tree containing mostly content in the form of Markdown files and some Jekyll related metadata. On my Gitea instance, I’ve set up a very simple post-receive Git hook, that triggers every time I push new changes to my repository. The hook pulls the changes into a working directory, executes Jekyll to build a functioning web site, and then pushes the result over SFTP to my web server, which then immediately is able to show the new contents.
A couple of days ago, the web site failed to build. The error messages I got were complaining about ruby31, and when I went to the gitea server and checked what version of Ruby it was running, it was in the 3.2 series, so at least why it failed was obvious. But I’m really not a Ruby expert so I was confused about how to get my script to understand that the system’s Ruby version has changed.
Having spent a couple of hours on troubleshooting I now have a better understanding:
In FreeBSD, you install the Ruby language and Gems through the system’s built-in package manager pkg
, and then you use Gems to install the Bundler package manager, and then you use Bundler’s bundle
command to execute Jekyll with all its dependencies. Straightforward and not messy at all to a beginner, right?
The issue I stumbled upon, was that the Ruby and Gems packages had been updated, but for some reason the bundle
command hadn’t followed along, so it was still trying to run an older version of Ruby.
As usual i scoured the web until I had built myself a mental model of what was happening, which let me narrow down my search terms until I found a working solution to the issue: Bundler needs to be updated too, but it’s done through Gems and therefore is not affected by system packages being updated. Adding the following line to my post-receive hook script before I execute Jekyll through Bundle seems to resolve the issue:
If Bundler is not installed, it will be so, and if an older version is installed, it will be lifted to a version that fits the Gems and Ruby versions executing the command.
Easy peasy.