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

16,526

Solution 1

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"

Solution 2

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).

Solution 3

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

Solution 4

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

Solution 5

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

Share:
16,526

Related videos on Youtube

reddyonrails
Author by

reddyonrails

experienced ruby on rails developer since 2005

Updated on July 09, 2021

Comments

  • reddyonrails
    reddyonrails almost 3 years

    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
    
  • Phil Gyford
    Phil Gyford over 9 years
    I didn't have to follow those extra steps - just updating XCode and running bundle install again did the job. Thanks!
  • lightyrs
    lightyrs over 5 years
    macports needs to be installed on the system level for it to work with sudo.

Related