Question

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:

https://github.com/ffi/ffi/issues/286

Note I had a bunch of stack overflow links here but I couldn't submit this question with them.

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top