LoadError: libffi.so.8: cannot open shared object file: No such file or directory running Rails

I am having trouble with creating a new rails project. When I run rails new project_name it comes to the rails webpacker:install it fails with the following error:

LoadError: libffi.so.8: cannot open shared object file: No such file or directory - /home/matija/.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/ffi-1.15.4/lib/ffi_c.so
/home/matija/Documents/learning-rails/course-project/config/application.rb:7:in `<main>'
/home/matija/Documents/learning-rails/course-project/Rakefile:4:in `<main>'
/home/matija/Documents/learning-rails/course-project/bin/rails:5:in `<top (required)>'
<internal:/home/matija/.asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
<internal:/home/matija/.asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
/home/matija/Documents/learning-rails/course-project/bin/spring:10:in `block in <top (required)>'
<internal:kernel>:90:in `tap'
/home/matija/Documents/learning-rails/course-project/bin/spring:7:in `<top (required)>'
bin/rails:2:in `load'
bin/rails:2:in `<main>'
Caused by:
LoadError: cannot load such file -- 3.0/ffi_c
/home/matija/Documents/learning-rails/course-project/config/application.rb:7:in `<main>'
/home/matija/Documents/learning-rails/course-project/Rakefile:4:in `<main>'
/home/matija/Documents/learning-rails/course-project/bin/rails:5:in `<top (required)>'
<internal:/home/matija/.asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
<internal:/home/matija/.asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
/home/matija/Documents/learning-rails/course-project/bin/spring:10:in `block in <top (required)>'
<internal:kernel>:90:in `tap'
/home/matija/Documents/learning-rails/course-project/bin/spring:7:in `<top (required)>'
bin/rails:2:in `load'
bin/rails:2:in `<main>'
(See full trace by running task with --trace)

I am using ASDF for ruby version management.

I tried many solutions like uninstalling and installing the gem, running gem pristine and some other methods that are provided on SO and here.

3

1 Answer

Thanks to @Knud Larsen, this worked for me on Ubuntu 20.04:

wget
sudo dpkg -i ./libffi8_3.4.2-1ubuntu5_amd64.deb

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like