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: _ffi_type_double #687

Closed
CHTJonas opened this issue Feb 26, 2019 · 3 comments
Closed

Symbol not found: _ffi_type_double #687

CHTJonas opened this issue Feb 26, 2019 · 3 comments

Comments

@CHTJonas
Copy link

CHTJonas commented Feb 26, 2019

I am experiencing the following error when I attempt to run a Rake task after having added gem 'ffi', '1.10.0' to the Gemfile of a freshly-generated Rails app.

This is with Ruby 2.6.1 and Bundler version 2.0.1 running on macOS 10.14.3.

Output of ruby -v:

ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-darwin18]

Output of bundle info ffi:

The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
  * ffi (1.10.0)
	Summary: Ruby FFI
	Homepage: http://wiki.github.com/ffi/ffi
	Path: /Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/ffi-1.10.0

Output of uname -a:

Darwin charlie-mbp-2013 18.2.0 Darwin Kernel Version 18.2.0: Thu Dec 20 20:46:53 PST 2018; root:xnu-4903.241.1~1/RELEASE_X86_64 x86_64 i386 MacBookPro11,3 Darwin

Here is the output of a sample Rake task eg. rake routes --trace:

rake aborted!
LoadError: dlopen(/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/lib/ffi_c.bundle, 9): Symbol not found: _ffi_type_double
  Referenced from: /Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/lib/ffi_c.bundle
  Expected in: flat namespace
 in /Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/lib/ffi_c.bundle - /Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/lib/ffi_c.bundle
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:83:in `register'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `block in require'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:257:in `load_dependency'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `require'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/lib/ffi.rb:6:in `rescue in <main>'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/lib/ffi.rb:3:in `<main>'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:83:in `register'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.0.1/lib/bundler/runtime.rb:81:in `block (2 levels) in require'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.0.1/lib/bundler/runtime.rb:76:in `each'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.0.1/lib/bundler/runtime.rb:76:in `block in require'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.0.1/lib/bundler/runtime.rb:65:in `each'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.0.1/lib/bundler/runtime.rb:65:in `require'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.0.1/lib/bundler.rb:114:in `require'
/private/tmp/testing/config/application.rb:7:in `<top (required)>'
/private/tmp/testing/Rakefile:4:in `require_relative'
/private/tmp/testing/Rakefile:4:in `<top (required)>'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-12.3.2/lib/rake/rake_module.rb:29:in `load'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-12.3.2/lib/rake/rake_module.rb:29:in `load_rakefile'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-12.3.2/lib/rake/application.rb:703:in `raw_load_rakefile'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-12.3.2/lib/rake/application.rb:104:in `block in load_rakefile'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-12.3.2/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-12.3.2/lib/rake/application.rb:103:in `load_rakefile'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-12.3.2/lib/rake/application.rb:82:in `block in run'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-12.3.2/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-12.3.2/lib/rake/application.rb:80:in `run'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
/Users/charlie/.rbenv/versions/2.6.1/bin/rake:23:in `load'
/Users/charlie/.rbenv/versions/2.6.1/bin/rake:23:in `<main>'

Caused by:
LoadError: cannot load such file -- 2.6/ffi_c
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:80:in `register'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:36:in `rescue in require'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:25:in `require'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `block in require'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:257:in `load_dependency'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `require'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/lib/ffi.rb:4:in `<main>'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:83:in `register'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.0.1/lib/bundler/runtime.rb:81:in `block (2 levels) in require'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.0.1/lib/bundler/runtime.rb:76:in `each'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.0.1/lib/bundler/runtime.rb:76:in `block in require'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.0.1/lib/bundler/runtime.rb:65:in `each'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.0.1/lib/bundler/runtime.rb:65:in `require'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.0.1/lib/bundler.rb:114:in `require'
/private/tmp/testing/config/application.rb:7:in `<top (required)>'
/private/tmp/testing/Rakefile:4:in `require_relative'
/private/tmp/testing/Rakefile:4:in `<top (required)>'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-12.3.2/lib/rake/rake_module.rb:29:in `load'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-12.3.2/lib/rake/rake_module.rb:29:in `load_rakefile'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-12.3.2/lib/rake/application.rb:703:in `raw_load_rakefile'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-12.3.2/lib/rake/application.rb:104:in `block in load_rakefile'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-12.3.2/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-12.3.2/lib/rake/application.rb:103:in `load_rakefile'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-12.3.2/lib/rake/application.rb:82:in `block in run'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-12.3.2/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-12.3.2/lib/rake/application.rb:80:in `run'
/Users/charlie/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
/Users/charlie/.rbenv/versions/2.6.1/bin/rake:23:in `load'
/Users/charlie/.rbenv/versions/2.6.1/bin/rake:23:in `<main>'
@larskanis
Copy link
Member

This looks like ruby-ffi is linked to a different libffi version at run time than that it was linked to while build time.

@CHTJonas
Copy link
Author

Looks like you're right - thanks for the help! Managed to solve with the following:

gem uninstall ffi
brew reinstall libffi
export LDFLAGS="-L/usr/local/opt/libffi/lib"
export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"
gem install ffi

@woozlik
Copy link

woozlik commented Mar 14, 2022

This looks like ruby-ffi is linked to a different libffi version at run time than that it was linked to while build time.

@larskanis hi, I would be thankful if you could help me. Project uses old version of ffi 1.10.0. I have mac with M1 processor

To install ffi 1.10.0 without error I use option in config file BUNDLE_BUILD__FFI: "--with-ffi_c-dir=/opt/homebrew/opt/libffi"
since homebrew for m1 has new locations for packages. When I run bundle exec foreman start I am getting almost the same as original error : symbol not found in flat namespace '_ffi_type_longdouble'.

I think your answer might be a root cause of my error, but I've tried steps from #687 (comment) and they didn't work. How can I link ruby-ffi to same libffi version at run time and build time?

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

3 participants