Web Analytics

tips@manuel:~$

How to fix Jekyll/Ruby v3 errors on Arch Linux/Manjaro

Today as I was updating my blogs (which run all on Jekyll) I encountered a series of errors when running bundle exec jekyll serve; mostly these three:

bundler: failed to load command: jekyll (/media/linux/.gems/bin/jekyll)

jekyll 3.9.0 | Error: no implicit conversion of Hash into Integer

/usr/local/lib/ruby/gems/3.0.0/gems/jekyll-3.9.0/lib/jekyll/commands/serve/servlet.rb:3:in 'require': cannot load such file -- webrick (LoadError)

As it turned out, the cause of this is that I had updated my Ruby version to 3, while neither Jekyll or the GitHub Pages gem (which all my themes use) have been updated to support it, and they require Ruby 2.7. The solution then is to downgrade the Ruby version, or preferably, to use RVM (Ruby Version Manager) to be able to run several Ruby versions simultaneously on the system.

I’m going to show how to do this on Arch Linux/Manjaro.

Firstly, delete everything in your .gems folder and also delete the .Gemlock file in your blog’s folder.

Then we install RVM from the AUR:

yay -S rvm ---noconfirm

Now let’s open the .bashrc file:

nano .bashrc

And paste this at the very bottom (the AUR script already adds a similar line there. You can leave it instead of this. I didn’t test if it works the same way):

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

Now let’s install Ruby 2.7:

rvm install 2.7

Then switch to a login shell (reason here):

/bin/bash --login

And set Ruby 2.7 as the default version:

rvm use 2.7 --default

It should all be ready. Now we can reinstall bundler:

gem install bundler

Reinstall all of the blog’s dependencies in their appropriate versions by running this inside the blog’s folder:

bundle install

And the blog should now be compiling and running in the local server:

bundle exec jekyll serve

Not so hard of a solution, but hopefully Jekyll and GitHub Pages are updated soon to support Ruby v3 so all of these steps are no longer necessary.

Source: DigitalOcean