6

I just upgraded to ubuntu 20.10 and when I tried to work with rails app that was working perfectly fine earlier started to show this error.

LoadError: libffi.so.7: cannot open shared object file: No such file or directory - 
/home/mahmud/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/ffi-1.13.1/lib/ffi_c.so

My rails version:6.0.3.4 Ruby Version: 2.7.1p83 I installed ruby using rbenv Can any one tell me what I have messed up?

4 Answers 4

8

Since Ubuntu 20.10 comes with libff8 instead of libffi7, I installed libffi7 by manually downloading the deb package from ubuntu focal (20.04):

wget http://es.archive.ubuntu.com/ubuntu/pool/main/libf/libffi/libffi7_3.3-4_amd64.deb
sudo dpkg -i libffi7_3.3-4_amd64.deb

After that I could successfully install the ffi gem.

This didn't require installing or changing any other packages. Also, the default libffi shared library seems to be libffi8:

$ ldconfig -p |  grep ffi
    libffi.so.8 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libffi.so.8
    libffi.so.8 (libc6) => /usr/lib/i386-linux-gnu/libffi.so.8
    libffi.so.7 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libffi.so.7
    libffi.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libffi.so
$ ls -l /usr/lib/x86_64-linux-gnu/libffi.so
lrwxrwxrwx 1 root root 15 ago 20 11:31 /usr/lib/x86_64-linux-gnu/libffi.so -> libffi.so.8.1.0

So far I haven't experienced any issues.

7

Ubuntu 20.04 came with a shared library called libffi.so.7, from the package libffi7. This library has been referenced by one of your ruby gems, ffi.

In the standard repos for Ubuntu 20.10 there's no package libffi7 anymore, so it has probably been removed from your system during the upgrade. Instead, Ubuntu 20.10 brings a package named libffi8ubuntu1.

You'll need at least to check whether the libffi8ubuntu1 package is installed and reinstall the ffi gem, so it references libffi8 instead of libff7. I don't know whether libffi8 just replaces libffi7 in your use case, or whether you need to make more changes. Possibly you need to wait until the developers up the chain (the developer of the ffi gem and so forth) have made any neccessary adjustments and then install the new versions.

6
  • 2
    I think reinstalling ffi gem will solve it and it has its own copy of that shared lib.
    – user.dz
    Oct 25, 2020 at 11:33
  • I already have package libffi8ubuntu1 installed and also I don't see any gem called ffi
    – MH Sagar
    Oct 25, 2020 at 11:46
  • @MHSagar The ffi gem was probably installed as a dependency of some other gem. It doesn't neccessarily show up in your applications Gemfile. For example, sassc pulls ffi as a dependency. You do have it, as your error message shows: /home/mahmud/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/ffi-1.13.1/lib/ffi_c.so Oct 25, 2020 at 12:39
  • So it means I can only until they update ffi gem?
    – MH Sagar
    Oct 25, 2020 at 14:26
  • @MHSagar You can try to update the ffi gem. It's not guaranteed that it will fix all your problems, but it's worth a try. gem update ffi. Oct 25, 2020 at 14:35
3

The answer by Henning Kockerbeck explains why it doesn't work - the newer Ubuntu version no longer provides the same shared system package BUT the gem was installed before the upgrade and still points to the old shared package.

Now, my fix may not work for you because I'm using rvm and not rbenv, but I think it might lead you down a useful route. I reinstalled the ruby version (for rvm this pretty much removes all the gems associated with that version and reinstalls them - this time pointing to the correct shared package).

rvm reinstall --disable-binary 2.5.7

The equivalent for rbenv might be:
rbenv uninstall 1.9.3-p0

rbenv install 1.9.3-p0

0

Updating ffi worked for me. You can run sudo gem update ffi to update it for your system globally, or bundle update ffi to update it for your current project.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.