Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ERROR: Error installing ffi: ERROR: Failed to build gem native extension

I am getting this error in Mac 64 bit and have xcode inatalled on machine.

Building native extensions.  This could take a while...
ERROR:  Error installing ffi:
    ERROR: Failed to build gem native extension.

/Users/jreddy/.rvm/rubies/ruby-1.8.7-p302/bin/ruby extconf.rb
checking for ffi.h in /usr/local/include... no
checking for rb_thread_blocking_region()... no
checking for ruby_thread_has_gvl_p()... no
checking for ruby_native_thread_p()... no
checking for rb_thread_call_with_gvl()... no
creating extconf.h
creating Makefile

make
sh: make: command not found
like image 399
reddyonrails Avatar asked Apr 11 '11 18:04

reddyonrails


People also ask

What is GEM FFI?

Ruby-FFI is a gem for programmatically loading dynamically-linked native libraries, binding functions within them, and calling those functions from Ruby code. Moreover, a Ruby-FFI extension works without changes on CRuby (MRI), JRuby, Rubinius and TruffleRuby.

How do I install a specific version of a gem?

Use `gem install -v` You may already be familiar with gem install , but if you add the -v flag, you can specify the version of the gem to install. Using -v you can specify an exact version or use version comparators.


5 Answers

A large portion of users are landing on this answer in an attempt to update the Xcode Command Line Tools. The easiest way to achieve this is by removing the old version of the tools, and installing the new one.

sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install

A popup will appear and guide you through the rest of the process.

After all, if xcode is installed correctly and you still have a problem, try installing ffi like this:

gem install ffi -v '1.9.18' -- --with-cflags="-Wno-error=implicit-function-declaration"
like image 125
fernandopso Avatar answered Oct 27 '22 17:10

fernandopso


I use homebrew, so after I did brew install libffi the gem installed for me. I have Xcode 4.2 tools active (with xcode-select). I did have to close and open a new Terminal window for home-brew's install to be recognised by the gem installation. But I could only get it working with ruby 1.8.7 but not 1.9.3 (using rvm).

like image 24
Matt Connolly Avatar answered Oct 27 '22 16:10

Matt Connolly


This one worked for me: brew link libffi --force

like image 29
Heriberto Magaña Avatar answered Oct 27 '22 15:10

Heriberto Magaña


Another version of answer, if you install libffi using brew then still does not work. You can try do this :

$ export PKG_CONFIG_PATH=/usr/local/Cellar/libffi/3.2.14/lib/pkgconfig/
$ gem install ffi
like image 22
surga Avatar answered Oct 27 '22 16:10

surga


I am also on OS X Lion. I re-installed XCode and ffi installed successfully using bundle install.

like image 29
dignoe Avatar answered Oct 27 '22 15:10

dignoe