4
votes

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.

1
Use the build-essential cookbook, to have the kernel/lib headers and a compiler.Tensibai
@Tensibai I don't suppose you have a working example of how to do this? I'm running into the same issue.user3505901
@user the working example to use the cookbook is in the Readme (mainly, add it to the node run list in the firsts one) , search for build-essential on supermarket.chef.io but I may have misunderstood your actual issue from the comment.Tensibai
@Tensibai, I needed a gem to be installed during the compilation phase of a chef run as most gems are. The problem is during this time in chef run, nothing else has happened so there is no compiler for the gem which requires native extensions so the installation fails. Just like for the OP.user3505901
@user IIRC the build-essential cookbook has an attribute to run at compile time, depending on your chef-client version the chef_gem resource run at compile or converge phase by defaultTensibai

1 Answers

0
votes

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