19

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
  • 81,219
  • 16
  • 124
  • 150
reddyonrails
  • 185
  • 1
  • 1
  • 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

11 Answers11

33

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
  • 575
  • 5
  • 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,608
  • 2
  • 61
  • 61
7

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

5

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,137
  • 15
  • 22
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,311
  • 3
  • 25
  • 39
  • 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
  • 973
  • 10
  • 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
  • 889
  • 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,488
  • 1
  • 19
  • 28
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,710
  • 2
  • 27
  • 31