Ram Haribabu
Ram Haribabu

Reputation: 41

Gem::Ext::BuildError: ERROR: Failed to build gem native extension - nio4r

I am trying to install all gems in my gemfile and its dependencies, so just ran the Bundler (bundle or bundle install). It failed while installing nio4r 1.1.1 with native extensions, below is log in gem_make.out.

/opscode/chef/embedded/bin/ruby.exe -r ./siteconf20150924-7480-ocwr34.rb extconf.rb
checking for unistd.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=/opscode/chef/embedded/bin/ruby
/opscode/chef/embedded/lib/ruby/2.0.0/mkmf.rb:434:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /opscode/chef/embedded/lib/ruby/2.0.0/mkmf.rb:565:in `try_cpp'
    from /opscode/chef/embedded/lib/ruby/2.0.0/mkmf.rb:1038:in `block in have_header'
    from /opscode/chef/embedded/lib/ruby/2.0.0/mkmf.rb:889:in `block in checking_for'
    from /opscode/chef/embedded/lib/ruby/2.0.0/mkmf.rb:340:in `block (2 levels) in postpone'
    from /opscode/chef/embedded/lib/ruby/2.0.0/mkmf.rb:310:in `open'
    from /opscode/chef/embedded/lib/ruby/2.0.0/mkmf.rb:340:in `block in postpone'
    from /opscode/chef/embedded/lib/ruby/2.0.0/mkmf.rb:310:in `open'
    from /opscode/chef/embedded/lib/ruby/2.0.0/mkmf.rb:336:in `postpone'
    from /opscode/chef/embedded/lib/ruby/2.0.0/mkmf.rb:888:in `checking_for'
    from /opscode/chef/embedded/lib/ruby/2.0.0/mkmf.rb:1037:in `have_header'
    from extconf.rb:3:in `'

extconf failed, exit code 1

I can see that the bundler is checking for the unistd.h and failing at that point. I made sure that this header is available within the PATH and also installed the ruby devkit for my version. Doing a gem install nio4r also gives the same error.

Upvotes: 4

Views: 1442

Answers (1)

archon92
archon92

Reputation: 447

try xcode-select --install first.This may be an issue with xcode build system

Upvotes: 0

Related Questions