Build fails on Ubuntu 20.04 due to missing libruby.so.2.7

Is Jekyll meant to be compatible with Ruby 2.7? Because I changed my CI script from using the ruby:2.5 Docker image to ubuntu:20.04, and now I can’t build my site. Rough instructions to reproduce:

docker run --mount type=bind,source=$(pwd),target=/src --interactive --rm --tty ubuntu:20.04 /bin/bash
apt-get update
apt-get install --assume-yes --no-install-recommends rubygems sudo
useradd foo
sudo --user=foo bundle install

The Gemfile just has Jekyll 4.2.0 and some plugins.

At this point, building fails:

root@1c7216fc743a:/src# sudo -u foo bundle exec jekyll build   
bundler: failed to load command: jekyll (/src/vendor/bundle/ruby/2.7.0/bin/jekyll)
Traceback (most recent call last):
	30: from /usr/local/bin/bundle:23:in `<main>'
	29: from /usr/local/bin/bundle:23:in `load'
	28: from /var/lib/gems/2.7.0/gems/bundler-2.2.5/exe/bundle:37:in `<top (required)>'
	27: from /var/lib/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/friendly_errors.rb:130:in `with_friendly_errors'
	26: from /var/lib/gems/2.7.0/gems/bundler-2.2.5/exe/bundle:49:in `block in <top (required)>'
	25: from /var/lib/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/cli.rb:24:in `start'
	24: from /var/lib/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
	23: from /var/lib/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/cli.rb:30:in `dispatch'
	22: from /var/lib/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
	21: from /var/lib/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	20: from /var/lib/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	19: from /var/lib/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/cli.rb:494:in `exec'
	18: from /var/lib/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/cli/exec.rb:28:in `run'
	17: from /var/lib/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/cli/exec.rb:63:in `kernel_load'
	16: from /var/lib/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/cli/exec.rb:63:in `load'
	15: from /src/vendor/bundle/ruby/2.7.0/bin/jekyll:23:in `<top (required)>'
	14: from /src/vendor/bundle/ruby/2.7.0/bin/jekyll:23:in `load'
	13: from /src/vendor/bundle/ruby/2.7.0/gems/jekyll-4.2.0/exe/jekyll:8:in `<top (required)>'
	12: from /src/vendor/bundle/ruby/2.7.0/gems/jekyll-4.2.0/exe/jekyll:8:in `require'
	11: from /src/vendor/bundle/ruby/2.7.0/gems/jekyll-4.2.0/lib/jekyll.rb:195:in `<top (required)>'
	10: from /src/vendor/bundle/ruby/2.7.0/gems/jekyll-4.2.0/lib/jekyll.rb:195:in `require'
	 9: from /src/vendor/bundle/ruby/2.7.0/gems/jekyll-sass-converter-2.1.0/lib/jekyll-sass-converter.rb:4:in `<top (required)>'
	 8: from /src/vendor/bundle/ruby/2.7.0/gems/jekyll-sass-converter-2.1.0/lib/jekyll-sass-converter.rb:4:in `require'
	 7: from /src/vendor/bundle/ruby/2.7.0/gems/jekyll-sass-converter-2.1.0/lib/jekyll/converters/scss.rb:3:in `<top (required)>'
	 6: from /src/vendor/bundle/ruby/2.7.0/gems/jekyll-sass-converter-2.1.0/lib/jekyll/converters/scss.rb:3:in `require'
	 5: from /src/vendor/bundle/ruby/2.7.0/gems/sassc-2.4.0/lib/sassc.rb:31:in `<top (required)>'
	 4: from /src/vendor/bundle/ruby/2.7.0/gems/sassc-2.4.0/lib/sassc.rb:31:in `require_relative'
	 3: from /src/vendor/bundle/ruby/2.7.0/gems/sassc-2.4.0/lib/sassc/native.rb:3:in `<top (required)>'
	 2: from /src/vendor/bundle/ruby/2.7.0/gems/sassc-2.4.0/lib/sassc/native.rb:3:in `require'
	 1: from /src/vendor/bundle/ruby/2.7.0/gems/ffi-1.14.2/lib/ffi.rb:4:in `<top (required)>'
/src/vendor/bundle/ruby/2.7.0/gems/ffi-1.14.2/lib/ffi.rb:4:in `require': cannot load such file -- 2.7/ffi_c (LoadError)
	31: from /usr/local/bin/bundle:23:in `<main>'
	30: from /usr/local/bin/bundle:23:in `load'
	29: from /var/lib/gems/2.7.0/gems/bundler-2.2.5/exe/bundle:37:in `<top (required)>'
	28: from /var/lib/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/friendly_errors.rb:130:in `with_friendly_errors'
	27: from /var/lib/gems/2.7.0/gems/bundler-2.2.5/exe/bundle:49:in `block in <top (required)>'
	26: from /var/lib/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/cli.rb:24:in `start'
	25: from /var/lib/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
	24: from /var/lib/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/cli.rb:30:in `dispatch'
	23: from /var/lib/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
	22: from /var/lib/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	21: from /var/lib/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	20: from /var/lib/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/cli.rb:494:in `exec'
	19: from /var/lib/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/cli/exec.rb:28:in `run'
	18: from /var/lib/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/cli/exec.rb:63:in `kernel_load'
	17: from /var/lib/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/cli/exec.rb:63:in `load'
	16: from /src/vendor/bundle/ruby/2.7.0/bin/jekyll:23:in `<top (required)>'
	15: from /src/vendor/bundle/ruby/2.7.0/bin/jekyll:23:in `load'
	14: from /src/vendor/bundle/ruby/2.7.0/gems/jekyll-4.2.0/exe/jekyll:8:in `<top (required)>'
	13: from /src/vendor/bundle/ruby/2.7.0/gems/jekyll-4.2.0/exe/jekyll:8:in `require'
	12: from /src/vendor/bundle/ruby/2.7.0/gems/jekyll-4.2.0/lib/jekyll.rb:195:in `<top (required)>'
	11: from /src/vendor/bundle/ruby/2.7.0/gems/jekyll-4.2.0/lib/jekyll.rb:195:in `require'
	10: from /src/vendor/bundle/ruby/2.7.0/gems/jekyll-sass-converter-2.1.0/lib/jekyll-sass-converter.rb:4:in `<top (required)>'
	 9: from /src/vendor/bundle/ruby/2.7.0/gems/jekyll-sass-converter-2.1.0/lib/jekyll-sass-converter.rb:4:in `require'
	 8: from /src/vendor/bundle/ruby/2.7.0/gems/jekyll-sass-converter-2.1.0/lib/jekyll/converters/scss.rb:3:in `<top (required)>'
	 7: from /src/vendor/bundle/ruby/2.7.0/gems/jekyll-sass-converter-2.1.0/lib/jekyll/converters/scss.rb:3:in `require'
	 6: from /src/vendor/bundle/ruby/2.7.0/gems/sassc-2.4.0/lib/sassc.rb:31:in `<top (required)>'
	 5: from /src/vendor/bundle/ruby/2.7.0/gems/sassc-2.4.0/lib/sassc.rb:31:in `require_relative'
	 4: from /src/vendor/bundle/ruby/2.7.0/gems/sassc-2.4.0/lib/sassc/native.rb:3:in `<top (required)>'
	 3: from /src/vendor/bundle/ruby/2.7.0/gems/sassc-2.4.0/lib/sassc/native.rb:3:in `require'
	 2: from /src/vendor/bundle/ruby/2.7.0/gems/ffi-1.14.2/lib/ffi.rb:3:in `<top (required)>'
	 1: from /src/vendor/bundle/ruby/2.7.0/gems/ffi-1.14.2/lib/ffi.rb:6:in `rescue in <top (required)>'
/src/vendor/bundle/ruby/2.7.0/gems/ffi-1.14.2/lib/ffi.rb:6:in `require': libruby.so.2.7: cannot open shared object file: No such file or directory - /src/vendor/bundle/ruby/2.7.0/extensions/x86_64-linux/2.7.0/ffi-1.14.2/ffi_c.so (LoadError)

Installing libruby does not help. A quick find / -name '*libruby*' shows that there is a /usr/lib/x86_64-linux-gnu/libruby-2.7.so.2.7, which presumably is exactly the file ffi_c is looking for, except with a slightly different name. I’m reluctant to just create a symlink without being sure that this is the actual problem, though.

Odd, I would think you’d see an error during the bundle install. When I tried with just the rubygems package, installing Jekyll would fail due to the lack of build tools.

Here’s the smoke test I used to successfully build a fresh Jekyll site with Ubuntu:20.04:

apt-get update
apt-get install build-essential ruby-full
gem install bundler jekyll
jekyll new foo
cd foo/
bundle exec jekyll build
2 Likes

Thank you! For others’ reference, I had to apt-get install build-essential imagemagick librsvg2-bin ruby ruby-dev sudo at minimum.

1 Like

The error was around a dev dependency .so file and related to ffi which I’ve also seen related to native extension compilation.

What likely liked this was as suggested by @chuckhoupt ruby-full on Linux, which includes ruby and ruby-dev if you read about it on Ubuntu registry. That allows for the compilation step

I ended up installing ruby and ruby-dev instead of ruby-full, since ruby-full also includes ruby-ri, which I don’t need.

1 Like