23

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
Ned Deily
  • 83,389
  • 16
  • 128
  • 151
reddyonrails
  • 225
  • 1
  • 2
  • 5
  • 2
    Re installed xcode tools again! It worked . – reddyonrails Apr 11 '11 at 22:51
  • You have to install development tools first. Could you check if you have XCode Command Line Tools installed? by running `xcode-select --install` From here: https://github.com/ffi/ffi/issues/937#issuecomment-1073265562 – Chaki_Black May 05 '22 at 06:48

14 Answers14

38

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"
fernandopso
  • 633
  • 6
  • 11
  • `gem install ffi -v '1.9.18' -- --with-cflags="-Wno-error=implicit-function-declaration"` works for me. thank you – anjarwidi83 Sep 21 '22 at 13:36
13

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

Heriberto Magaña
  • 882
  • 10
  • 11
13

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

Matt Connolly
  • 9,757
  • 2
  • 65
  • 61
6

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
surga
  • 1,436
  • 21
  • 25
2

Updating the Command Line Tools within XCode and following these steps: https://stackoverflow.com/a/10610951/1691 did it for me

Community
  • 1
  • 1
olore
  • 4,687
  • 3
  • 28
  • 40
  • 1
    I didn't have to follow those extra steps - just updating XCode and running `bundle install` again did the job. Thanks! – Phil Gyford Sep 22 '14 at 07:35
2

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

dignoe
  • 1,013
  • 11
  • 17
1

Updating X-code on my Mac OS-X Maverics made it work for me

MoA
  • 61
  • 2
1

I had this problem on OSX 10.10.15 with ruby-2.0.0-p481 under rvm. All i had to do was

sudo xcodebuild -license

It won't fix all cases but it might fix some

dabobert
  • 919
  • 12
  • 10
1

If gem install ffi -v '1.9.21' --source 'https://rubygems.org/ did not solve the problem. Then it seems like in Mac ffi-1.19.21 is trying to using ffi_prep_closure_loc() and system-libffi which doesn’t have.

Try this temporary solution:

gem install ffi -- --disable-system-libffi

More details here: https://github.com/ffi/ffi/issues/791

suvankar
  • 1,548
  • 1
  • 20
  • 28
1

For me, it worked with this,

I had issue with React Native ios when running


bundle install

An error occurred while installing ffi (1.15.5), and Bundler cannot continue. Make sure that gem install ffi -v '1.15.5' --source 'https://rubygems.org/' succeeds before bundling.

Resolved this error by doing this.

export LDFLAGS="-L/usr/local/opt/libffi/lib"
export CPPFLAGS="-I/usr/local/opt/libffi/include"
export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"


0

I was using ree-1.8.7-2010.02 and there was no way the install would work. Switched to ruby-1.9.2 and it worked like a charm.

jibril
  • 43
  • 5
0

I had this same problem on OS X Lion and solved it by doing:

sudo port install libffi
lightyrs
  • 2,809
  • 2
  • 29
  • 32
0

To fix this, I had to add the following environment variables to my ~/.profile/~/.bash_profile:

export SDKROOT=$(xcrun --sdk macosx --show-sdk-path)
export LIBRARY_PATH="/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib"

Once I added those, I was able to install the ffi Gem.

Note that you may need to install/setup the Xcode SDK/libraries first via:

xcode-select --install
sudo xcodebuild -license
sudo xcode-select --switch /Applications/Xcode.app
stiemannkj1
  • 4,418
  • 3
  • 25
  • 45
0

What worked for me, first:

gem install ffi -v '1.15.5' -- --with-cflags="-Wno-error=implicit-function-declaration"

Then:

gem pristine ffi --version 1.15.5