Miskatonic University Press

Ruby 3.2 problem with Jekyll

jekyll ruby

Late last year Ruby 3.2.0 was released. I bumped Conforguration to use this version and updated to it with two commands (the first to update rbenv with current information about Ruby versions):

$ ~/conforg/scripts/ruby-rbenv.sh
$ ~/conforg/scripts/ruby-install-personal.sh

Now I have Ruby 3.2.0 installed and it’s the default version. Good. But …

I use Jekyll to run this site, and the source is in my ~/web/ directory. I wanted to make sure it worked with the new Ruby version, so I began by updating Bundler and the required Ruby gems (third-party software packages).

$ cd ~/web/
$ bundle update --bundler

That worked. But then I ran this to build the site (actually, I ran make, because I have a Makefile to simplify things, but I won’t get into that):

$ bundle exec jekyll build
Configuration file: /home/wtd/web/_config.yml
            Source: /home/wtd/web
       Destination: /var/www/miskatonic/local/dynamic
 Incremental build: disabled. Enable with --incremental
      Generating...
  Liquid Exception: undefined method `tainted?' for "https://www.miskatonic.org":String in /home/wtd/web/_layouts/post.html
                    ------------------------------------------------
      Jekyll 4.2.0   Please append `--trace` to the `build` command
                     for any additional information or backtrace.
                    ------------------------------------------------
/home/wtd/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/liquid-4.0.3/lib/liquid/variable.rb:124:in `taint_check': undefined method `tainted?' for "https://www.miskatonic.org":String (NoMethodError)
  return unless obj.tainted?
                   ^^^^^^^^^

It turns out that Liquid 4 is not compatible with Ruby 3.2. Liquid is the templating language Jekyll uses. Liquid is now at version 5, but there’s a small problem preventing Jekyll from using it, so Jekyll still uses version 4, yet version 4 doesn’t work with Ruby 3.2. Thus my error.

However, this isn’t a fatal problem (as you can tell because I am posting about it) because rbenv lets me specify a particular version of Ruby for a given project.

$ rbenv versions
system
3.0.1
3.1.0
3.1.1
* 3.2.0 (set by /home/wtd/.rbenv/version)
$ rbenv local
rbenv: no local version configured for this directory
$ rbenv local 3.1.1
$ rbenv local
3.1.1
$ cat .ruby-version
3.1.1

Now I’m using Ruby 3.2 generally but 3.1.1 for this Jekyll project, and everything works.

Writing this out I see how complicated it all is, but static site generators like Jekyll are the simple way of making web sites! Everything about the web is vastly more complicated than it was way back when. Nevertheless, after nine years I’m still very happy I moved to Jekyll. It helps keep things about as simple as they can be.

UPDATE (2023-04-29): The bug is now fixed. I removed .ruby-version, ran bundle install and bundle update (both were needed for some reason) and now my regular build process works normally.