ffi: "Could not create Makefile due to some reason"

I keep getting this error when I try to install ffi. I’ve googled it a bit, but haven’t been able to come up with anything that would make it install. Please advice.

Error:

➜  Vendor git:(master) ✗ sudo gem install ffi
Building native extensions.  This could take a while...
ERROR:  Error installing ffi:
  ERROR: Failed to build gem native extension.

    /Users/holgersindbaek/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb
checking for ffi.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
  --with-opt-dir
  --with-opt-include
  --without-opt-include=${opt-dir}/include
  --with-opt-lib
  --without-opt-lib=${opt-dir}/lib
  --with-make-prog
  --without-make-prog
  --srcdir=.
  --curdir
  --ruby=/Users/holgersindbaek/.rvm/rubies/ruby-1.9.3-p448/bin/ruby
  --with-ffi_c-dir
  --without-ffi_c-dir
  --with-ffi_c-include
  --without-ffi_c-include=${ffi_c-dir}/include
  --with-ffi_c-lib
  --without-ffi_c-lib=${ffi_c-dir}/lib
  --with-libffi-config
  --without-libffi-config
  --with-pkg-config
  --without-pkg-config
/Users/holgersindbaek/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
  from /Users/holgersindbaek/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp'
  from /Users/holgersindbaek/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:931:in `block in have_header'
  from /Users/holgersindbaek/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
  from /Users/holgersindbaek/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
  from /Users/holgersindbaek/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:254:in `open'
  from /Users/holgersindbaek/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
  from /Users/holgersindbaek/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:254:in `open'
  from /Users/holgersindbaek/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
  from /Users/holgersindbaek/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
  from /Users/holgersindbaek/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:930:in `have_header'
  from extconf.rb:16:in `<main>'


Gem files will remain installed in /Users/holgersindbaek/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/gems/1.9.1/gems/ffi-1.9.0 for inspection.
Results logged to /Users/holgersindbaek/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/gems/1.9.1/gems/ffi-1.9.0/ext/ffi_c/gem_make.out

About this issue

  • Original URL
  • State: closed
  • Created 11 years ago
  • Reactions: 7
  • Comments: 27 (1 by maintainers)

Most upvoted comments

$ apt-get install build-essential dh-autoreconf  # :^)

got the same issue. impossible for me to solve this issue. but using brew worked for me

brew install cocoapods

You probably need to install the xcode command line tools - http://railsapps.github.io/xcode-command-line-tools.html

If you already have the command line tools installed, resetting it to the default path can help:

xcode-select --reset

You’re using brew as your package manager?
If so, see if this fixes it:

brew install libffi

On Linux, try installing the development support files for zlib, e.g.

sudo apt-get install libz-dev

I faced this issue after upgrading to MacOS Mojave. All you need is to install Xcode again:

xcode-select --install

got the same issue. impossible for me to solve this issue. but using brew worked for me

brew install cocoapods

For me. I had to re-install Xcode command line tools and then use brew to install Cocoapods. Idk which one worked but nothing else was working.

Ubuntu 22.04 LTS

sudo apt install -y ruby ruby-dev ruby-colorize sudo apt-get install -y libncurses5-dev libtinfo-dev sudo apt-get install libz-dev sudo apt-get install build-essential dh-autoreconf sudo gem install colorls

colorls -A

still error on ubuntu 16

Installing ffi (1.9.14)
Building native extensions.  This could take a while...
ERROR:  While executing gem ... (Gem::Ext::BuildError)
    ERROR: Failed to build gem native extension.

    /usr/bin/ruby2.1 extconf.rb
checking for ffi.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
	--with-opt-dir
	--without-opt-dir
	--with-opt-include
	--without-opt-include=${opt-dir}/include
	--with-opt-lib
	--without-opt-lib=${opt-dir}/lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=/usr/bin/ruby2.1
	--with-ffi_c-dir
	--without-ffi_c-dir
	--with-ffi_c-include
	--without-ffi_c-include=${ffi_c-dir}/include
	--with-ffi_c-lib
	--without-ffi_c-lib=${ffi_c-dir}/lib
	--with-libffi-config
	--without-libffi-config
	--with-pkg-config
	--without-pkg-config
/usr/lib/ruby/2.1.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
	from /usr/lib/ruby/2.1.0/mkmf.rb:587:in `try_cpp'
	from /usr/lib/ruby/2.1.0/mkmf.rb:1061:in `block in have_header'
	from /usr/lib/ruby/2.1.0/mkmf.rb:912:in `block in checking_for'
	from /usr/lib/ruby/2.1.0/mkmf.rb:351:in `block (2 levels) in postpone'
	from /usr/lib/ruby/2.1.0/mkmf.rb:321:in `open'
	from /usr/lib/ruby/2.1.0/mkmf.rb:351:in `block in postpone'
	from /usr/lib/ruby/2.1.0/mkmf.rb:321:in `open'
	from /usr/lib/ruby/2.1.0/mkmf.rb:347:in `postpone'
	from /usr/lib/ruby/2.1.0/mkmf.rb:911:in `checking_for'
	from /usr/lib/ruby/2.1.0/mkmf.rb:1060:in `have_header'
	from extconf.rb:16:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.1.0/gems/ffi-1.9.14 for inspection.
Results logged to /var/lib/gems/2.1.0/extensions/x86_64-linux/2.1.0/ffi-1.9.14/gem_make.out

I basically get the same error:

ERROR:  While executing gem ... (Errno::EACCES)
    Permission denied - /Users/holgersindbaek/.rvm/gems/ruby-1.9.3-p448/gems/ffi-1.9.0/ffi.gemspec

Why do you think the ruby install is screwed up? Everything else is working.

What happens if you just try to do

gem install ffi

It sounds like you’ve got your ruby install a bit screwed up now - I would uninstall that version from rvm and re-install it first.

@holgersindbaek You’ll need to check the actual errors in /Users/holgersindbaek/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/gems/1.9.1/gems/ffi-1.9.0/ext/ffi_c/gem_make.out

Have you installed other C based exts, like nokogiri?