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

ffi fails to build via bundler on MacOS 10.8.5 #342

Closed
mattmartini opened this issue May 12, 2014 · 4 comments
Closed

ffi fails to build via bundler on MacOS 10.8.5 #342

mattmartini opened this issue May 12, 2014 · 4 comments

Comments

@mattmartini
Copy link

PROBLEM:
bundler fails to build ffi and so my rails apps are broken in my development environment.
None of the posts that I've read have solutions that work for me. I get the same error in a number of rails apps.

What other troubleshooting steps can I take?
How do I fix this issue?

BACKGROUND:
After an upgrade to Mountain Lion from Snow Leopard, Xcode upgrade, Clean Homebrew install, I did a clean install of rvm. Now I am trying to recreate the gemsets used by my rails apps. I did:
gem install rails -v3.2.16 (to get the base rails gems installed)
rvm gemset import ruby-1.9.3-p545@CLIENTNAME.gems (to import gems)
bundle install (to install dependencies and resync gemfile.lock)

ISSUE:
bundle install fails with this error message:
An error occurred while installing ffi (1.9.3), and Bundler cannot continue.
Make sure that gem install ffi -v '1.9.3' succeeds before bundling.

The complete gem_make.out is here: https://gist.github.com/mattmartini/b2f8ad3b4e6c57325d38

The mkmf.log is here: https://gist.github.com/mattmartini/d3256cb52e5eafb2346b

The config.log is here: https://gist.github.com/mattmartini/69407e118e92cadda2b0

I would like to stay on ruby 1.9.3 as the Production servers are using this.

OBSERVATIONS:
One of the errors thrown is that 'C compiler cannot create executables' - this is not true. I can compile C programs and bundler built nokogiri without a problem.

I did just notice that libffi, which was installed (along with gcc46) by rvm, is keg only. Would bundler be able to use the lib in creating the gem?

ENVIRONMENT:
Mac OS X 10.8.5 (Mountain Lion)
Xcode 5.0.2 (command line tools installed)
Homebrew 0.9.5 (recent fresh install)
rvm 1.25.25 (stable)
ruby 1.9.3-p545
libffi 3.0.13 (brew via rvm)
gcc46 (brew via rvm)

REVIEWED:
I reviewed a number of posts of similar issues, but none had a solution that worked for me, including:
#286
https://stackoverflow.com/questions/10575679/bundle-update-fails-on-ffi
https://stackoverflow.com/questions/7491606/cant-install-ffi-gem-rails-fail
https://stackoverflow.com/questions/11725577/an-error-occured-while-installing-ffi-1-1-2-and-bundler-cannot-continue

@mattmartini
Copy link
Author

Following the advice of a stact overflow post, I removed ~/.gem, .bundle, vendor.cache, and Gemfile.lock before retrying bundle install. The same error was thrown.

@mattmartini
Copy link
Author

My hunch about libffi being keg only was correct. After linking libffi, bundle used this lib instead of trying to compile it. This resolves the issue of getting the gem installed, but doesn't resolve why it fails to compile.

Since the lib is keg only you have to force it to link:

brew link libffi --force

The failure to compile should still be investigated.

@cloudbring
Copy link

As a note, I was experiencing this error. The advice given was to use:

$ xcode-select -p and look for the output

/Applications/Xcode.app/Contents/Developer

When I tried to use gcc I got the following error:



Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.

After that, I had to:

$ sudo gcc

Which then asks me to sign a EULA for clang on the command-line before I can use gcc (which on OSX is an alias for clang).

Agreeing solved the problem when ti came to installing.

$ gem install ffi -v '1.9.10' worked fine

@baranyeni
Copy link

baranyeni commented Dec 8, 2021

Thank you so much @mattmartini

I fixed that problem with following steps.

brew link libffi --force
gem install ffi -v '1.9.18' -- --with-cflags="-Wno-error=implicit-function-declaration"

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