Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a controller with rails generate is causing a strange error

I tried to start a simple rails app today to refresh my knowledge and ran into a very strange issue...

  1. Created app (rails new app-name).
  2. Created controller with index action (rails g controller site index).
  3. Set the root route to site#index.
  4. Start rails server.

The server tries to render the index view for site, but aborts abruptly with the following error:

dyld: lazy symbol binding failed: Symbol not found: _ffi_prep_closure_loc
Referenced from: /Users/Marco/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/ffi-1.13.1/lib/ffi_c.bundle
  Expected in: /usr/lib/libffi.dylib

dyld: Symbol not found: _ffi_prep_closure_loc
  Referenced from: /Users/Marco/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/ffi-1.13.1/lib/ffi_c.bundle
  Expected in: /usr/lib/libffi.dylib

I tried (unsuccessfully):

  • Upgrading my ruby version, then my rails version to latest.
  • Reinstalling all my gems.
  • Deleting the path to ffi_c.bundle and reinstalling ffi.

What is strange is that if I manually create the controller and the view, everything works fine!

I saw a suggestion on a somewhat related issue to try to change the C compiler on my machine to the default, but I don't understand why that would be necessary and I'd like to get a deeper understanding about what's going on.

like image 866
K.DBTC Avatar asked Jun 09 '20 20:06

K.DBTC


2 Answers

I am having the same issues, and yes the file exists. I rolled my project back to ffi '~> 1.12.2' and it is working fine again.

like image 198
Travis Avatar answered Nov 17 '22 09:11

Travis


It seems the issue has something to do with libffi version conflicts.

A workaround: gem inst ffi -- --disable-system-libffi

I raised an issue, see here: https://github.com/ffi/ffi/issues/791

like image 33
K.DBTC Avatar answered Nov 17 '22 09:11

K.DBTC