Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

symbol not found in flat namespace '_ffi_prep_closure' #946

Open
chrisgeek opened this issue Mar 21, 2022 · 9 comments
Open

symbol not found in flat namespace '_ffi_prep_closure' #946

chrisgeek opened this issue Mar 21, 2022 · 9 comments

Comments

@chrisgeek
Copy link

Macbook Pro
Chip: Apple M1 Pro
Ruby: 2.5.6
Rails : 4.2

When trying to setup a legacy ruby on rails application on my Macbook, I get stuck trying to run rails s with the following error
require': dlopen(/Users/chrisgeeq/.rbenv/versions/2.5.9/lib/ruby/gems/2.5.0/gems/ffi-1.9.25/lib/ffi_c.bundle, 0x0009): symbol not found in flat namespace '_ffi_prep_closure' - /Users/chrisgeeq/.rbenv/versions/2.5.9/lib/ruby/gems/2.5.0/gems/ffi-1.9.25/lib/ffi_c.bundle (LoadError)
I have tried reinstalling the ffi gem but the problem persist, not sure what to do at this point.

@nowsta-olli
Copy link

I encountered the same issue with ruby 2.5.7 and ffi 1.12.2

I manually changed the ffi version to 1.15.2 in Gemfile.lock and ran bundle again, this fixed the issue for me

@karansapolia
Copy link

I encountered the same issue with ruby 2.5.7 and ffi 1.12.2

I manually changed the ffi version to 1.15.2 in Gemfile.lock and ran bundle again, this fixed the issue for me

This did not work for me. Getting the same error.

@imvishi
Copy link

imvishi commented Apr 19, 2022

I encountered the same issue with ruby 2.5.7 and ffi 1.12.2

I manually changed the ffi version to 1.15.2 in Gemfile.lock and ran bundle again, this fixed the issue for me

Thanks @nowsta-olli , this helped me to resolve this issue.

@jakerobers
Copy link

This also solved the issue for me. Thank you @nowsta-olli

@gurgelrenan
Copy link

gurgelrenan commented Jul 19, 2022

This works for me, thanks @nowsta-olli

@jjercx
Copy link

jjercx commented Aug 19, 2022

Bumping 1.9.25 for 1.15.5 did the trick for me

@Umofomia
Copy link

Umofomia commented Sep 9, 2022

I ran into the same problem on an Apple M1. In my case, my project had to remain on ffi version 1.12.2 so I could not upgrade the version. However, I was finally able to get it to work by reinstalling ffi with the following options:

gem install ffi -v 1.12.2 -- --with-ldflags="-L$(brew --prefix libffi)/lib" --with-pkg-config-path="$(brew --prefix libffi)/lib/pkgconfig"

If you want bundler to automatically use these options when installing ffi, you can do the following:

bundle config build.ffi "--with-ldflags=-L$(brew --prefix libffi)/lib --with-pkg-config-path=$(brew --prefix libffi)/lib/pkgconfig"

I was able to arrive at this solution after finding this comment by @reaperhulk for a similar issue in a Python project:

This issue keeps cropping up and it appears to be an issue where the Homebrew libffi include path is being passed as part of the compilation args, but the linker is using the system libffi. This results in this error at runtime. You can work around this if you understand how to pass the correct linker paths, but that's not the right long term solution. I'm not sure what (if anything) Homebrew has changed around this, but it will continue to be a problem until the root issue (which is unrelated to cffi or cryptography) is resolved.

@Faq
Copy link

Faq commented Oct 30, 2022

M1 v13 Ventura, you should be able to install older version with:
gem install ffi -v '1.11.1' -- --enable-libffi-alloc
ref. #800 (comment)

but problem was when running after rake db:create got again same error.
So only what did help, like mentioned in reference:

gem install ffi -v '1.14.0'
And changing also to this version in gemfile.lock

@sabirsaifi
Copy link

sabirsaifi commented Nov 4, 2022

I encountered the same issue with ruby 2.5.7 and ffi 1.12.2

I manually changed the ffi version to 1.15.2 in Gemfile.lock and ran bundle again, this fixed the issue for me

It works. Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants