12

I'm newbie in rails and I'm working on Ubuntu 19.10 yesterday I decide to upgrade my OS to new version every things is going fine after upgrading finished after t i start to use my computer to develop that found any rails command not works and showed me this error

in `require': libffi.so.6: cannot open shared object file: No such file or directory - /home/ace/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/ffi-1.13.1/lib/ffi_c.so (LoadError)

I found people with same issues but none of them have problem in rails and any of them is useful for me .

I think the problem is about libffi.so.6 package because ffi-1.13.1 is installed on my OS

Hadii Varposhti
  • 416
  • 4
  • 22
  • you can try this answer : [solution](https://stackoverflow.com/questions/61875869/ubuntu-20-04-upgrade-python-missing-libffi-so-6) it working with me. – ThinhNguyen Dec 10 '20 at 07:55
  • @ThinhNguyen Thanks Dude it solve my problem, add your comment as answer to set this answer useful – Hadii Varposhti Dec 12 '20 at 13:30

7 Answers7

14

Ubuntu 20.04 upgraded libffi6 to libffi7 but your Rails apps are still looking for libffi6. You need to run the following command:

gem pristine ffi

This should fix it

vvvvv
  • 25,404
  • 19
  • 49
  • 81
clemoun
  • 298
  • 3
  • 14
4

gem pristine ffi did not help for me. The more invasive

gem uninstall ffi
gem install ffi

did the job.

codener
  • 464
  • 1
  • 8
  • 27
1

Adding gem "ffi", github: "ffi/ffi" to my Gemfile fixed it

Dorian
  • 7,749
  • 4
  • 38
  • 57
  • The GitHub part might not be valid anymore. I got this error when installing the gem: fatal: not a git repository: 'ext/ffi_c/libffi/.git' – Jared Menard Jan 07 '22 at 15:14
0
  1. it requires you to rebuild when you switch rubies.

  2. Annoyingly, it seems like it also seems to fail into this message even when installed and you also try to use byebug debugger. (It does this for me even when the ffi binary is otherwise installed-- and taking out the byebug debugger does not fall into this ffi error)

Using ruby/debug seems to work

Jason FB
  • 4,752
  • 3
  • 38
  • 69
0

My error was libffi 8 on ubuntu 20.04 for rails 6.1.4

https://github.com/ffi/ffi#requirements solved my issue

--enable-system-libffi : Force usage of system libffi
--disable-system-libffi : Force usage of builtin libffi
--enable-libffi-alloc : Force closure allocation by libffi
--disable-libffi-alloc : Force closure allocation by builtin method
Ram on Rails
  • 1,299
  • 11
  • 25
0

I had the same issue here: https://github.com/ffi/ffi/issues/947#issuecomment-1089299217

First uninstall the gem:

gem uninstall ffi

then reinstall it with:

gem install ffi -- --disable-system-libffi

-1

Here's what helped me:

  1. Drop your project's vendor/cache folder
  2. bundle install
Marat
  • 622
  • 7
  • 21