How to Solve "LoadError: cannot load such file -- 2.5/ffi_c" Running Ruby on Rails with WSL

Viewed 211

I'm trying to get a (private) Ruby on Rails application up and running on my Windows machine using Windows Subsystem for Linux (WSL). I was able to run bundle install without any errors but now when I run rails apartment:create I get the error:

LoadError: libffi.so.8: cannot open shared object file: No such file or directory - /home/myDirectory/.rvm/gems/ruby-2.5.7/gems/ffi-1.11.1/lib/ffi_c.so

Complete error is below.

I tried reinstalling ruby with rvm get head and rvm reinstall 2.5.7, reinstalling ffi with gem uninstall ffi and gem install ffi -v 1.11.1, and creating a symbolic link with ln -s libffi.so.8 libffi.so.1.8, but get the same result.

I see the referenced file is there: enter image description here

Anything else I can try?

me@LAPTOP-xyz:/mnt/c/Users/me/Documents/app/Application/master$ rails apartment:create
rails aborted!
LoadError: libffi.so.8: cannot open shared object file: No such file or directory - /home/me/.rvm/gems/ruby-2.5.7/gems/ffi-1.11.1/lib/ffi_c.so
/home/me/.rvm/gems/ruby-2.5.7/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
/home/me/.rvm/gems/ruby-2.5.7/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
/home/me/.rvm/gems/ruby-2.5.7/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
/home/me/.rvm/gems/ruby-2.5.7/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
/home/me/.rvm/gems/ruby-2.5.7/gems/ffi-1.11.1/lib/ffi.rb:6:in `rescue in <top (required)>'
/home/me/.rvm/gems/ruby-2.5.7/gems/ffi-1.11.1/lib/ffi.rb:3:in `<top (required)>'
/mnt/c/Users/me/Documents/app/Application/master/config/application.rb:18:in `<top (required)>'
/mnt/c/Users/me/Documents/app/Application/master/rakefile:4:in `require_relative'
/mnt/c/Users/me/Documents/app/Application/master/rakefile:4:in `<top (required)>'
/home/me/.rvm/gems/ruby-2.5.7/gems/railties-5.2.3/lib/rails/commands/rake/rake_command.rb:22:in `block in perform'
/home/me/.rvm/gems/ruby-2.5.7/gems/railties-5.2.3/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/home/me/.rvm/gems/ruby-2.5.7/gems/railties-5.2.3/lib/rails/command.rb:48:in `invoke'
/home/me/.rvm/gems/ruby-2.5.7/gems/railties-5.2.3/lib/rails/commands.rb:18:in `<top (required)>'
/mnt/c/Users/me/Documents/app/Application/master/bin/rails:9:in `require'
/mnt/c/Users/me/Documents/app/Application/master/bin/rails:9:in `<top (required)>'
/home/me/.rvm/gems/ruby-2.5.7/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
/home/me/.rvm/gems/ruby-2.5.7/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
/home/me/.rvm/gems/ruby-2.5.7/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
/home/me/.rvm/gems/ruby-2.5.7/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
/home/me/.rvm/gems/ruby-2.5.7/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
/home/me/.rvm/gems/ruby-2.5.7/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
/home/me/.rvm/gems/ruby-2.5.7/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
/mnt/c/Users/me/Documents/app/Application/master/bin/spring:15:in `require'
/mnt/c/Users/me/Documents/app/Application/master/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'

Caused by:
LoadError: cannot load such file -- 2.5/ffi_c
/home/me/.rvm/gems/ruby-2.5.7/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
/home/me/.rvm/gems/ruby-2.5.7/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
/home/me/.rvm/gems/ruby-2.5.7/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
/home/me/.rvm/gems/ruby-2.5.7/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
/home/me/.rvm/gems/ruby-2.5.7/gems/ffi-1.11.1/lib/ffi.rb:4:in `<top (required)>'
/mnt/c/Users/me/Documents/app/Application/master/config/application.rb:18:in `<top (required)>'
/mnt/c/Users/me/Documents/app/Application/master/rakefile:4:in `require_relative'
/mnt/c/Users/me/Documents/app/Application/master/rakefile:4:in `<top (required)>'
/home/me/.rvm/gems/ruby-2.5.7/gems/railties-5.2.3/lib/rails/commands/rake/rake_command.rb:22:in `block in perform'
/home/me/.rvm/gems/ruby-2.5.7/gems/railties-5.2.3/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/home/me/.rvm/gems/ruby-2.5.7/gems/railties-5.2.3/lib/rails/command.rb:48:in `invoke'
/home/me/.rvm/gems/ruby-2.5.7/gems/railties-5.2.3/lib/rails/commands.rb:18:in `<top (required)>'
/mnt/c/Users/me/Documents/app/Application/master/bin/rails:9:in `require'
/mnt/c/Users/me/Documents/app/Application/master/bin/rails:9:in `<top (required)>'
/home/me/.rvm/gems/ruby-2.5.7/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
/home/me/.rvm/gems/ruby-2.5.7/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
/home/me/.rvm/gems/ruby-2.5.7/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
/home/me/.rvm/gems/ruby-2.5.7/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
/home/me/.rvm/gems/ruby-2.5.7/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
/home/me/.rvm/gems/ruby-2.5.7/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
/home/me/.rvm/gems/ruby-2.5.7/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
/mnt/c/Users/me/Documents/app/Application/master/bin/spring:15:in `require'
/mnt/c/Users/me/Documents/app/Application/master/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
(See full trace by running task with --trace)
1 Answers

I'm not sure what your current setup is, but I recently ran into a similar issue as this error with WSL.

For me, I believe the issued was when I had installed ffmpeg through Homebrew for Linux. In doing brew install ffmpeg, I believe it added a brew install ffi as a result of its dependencies, causing something on my system to change with regard to FFI.

After re-installing (through rbenv) a couple of times to no-avail, I finally did a brew uninstall ffi --ignore-dependencies and then did another rbenv install 2.7.4.

After this, I was successfully able to gem install llhttp-ffi -v 0.4.0 whereas I wasn't able to before because of the same error message you are receiving.

Apologies for not having any other specifics other than having the same error as you. Hope you get pointed in the right direction.

Related