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

reddyonrails picture reddyonrails · Apr 11, 2011 · Viewed 11.3k times · Source

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

Answer

Fernando picture Fernando · Sep 15, 2020

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"