Gem :: Ext :: BuildError:错误:无法构建gem原生扩展--nio4r

时间:2015-09-24 13:27:31

标签: ruby gem chef

我正在尝试在我的gemfile及其依赖项中安装所有gem,因此只需运行Bundler(bundle或bundle install)。在使用本机扩展安装nio4r 1.1.1时失败,下面是登录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

我可以看到捆绑器正在检查unistd.h并且在那时失败了。我确保此标头在PATH中可用,并且还为我的版本安装了ruby devkit。执行gem install nio4r也会出现同样的错误。

1 个答案:

答案 0 :(得分:0)

首先尝试xcode-select --install。这可能是xcode构建系统的问题