Gem::Ext::BuildError: ERROR: 无法构建本地扩展宝石 - nio4r

4
我正在尝试安装Gemfile中的所有gems及其依赖项,因此只需运行Bundler(bundle或bundle install)。 在安装nio4r 1.1.1时出现本机扩展错误,下面是gem_make.out中的日志。
/opscode/chef/embedded/bin/ruby.exe -r ./siteconf20150924-7480-ocwr34.rb extconf.rb
检查unistd.h... *** extconf.rb失败 ***
由于某些原因(可能是缺少必要的库和/或标头文件),无法创建Makefile。有关更多详细信息,请检查mkmf.log文件。您可能需要配置选项。
提供的配置选项:     --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': 编译器无法生成可执行文件。(RuntimeError) 首先,您需要安装开发工具。     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失败,退出代码1
我可以看到bundler正在检查unistd.h并在该点上失败。 我确保此标头在PATH中可用,并为我的版本安装了ruby devkit。 运行gem install nio4r也会出现相同的错误。

1
使用 build-essential cookbook,以获取内核/库头文件和编译器。 - Tensibai
@Tensibai,我不知道你是否有一个可行的示例来演示如何做到这一点?我也遇到了同样的问题。 - user3505901
@user,使用菜谱的工作示例在Readme中(主要是将其添加到第一个节点运行列表中),请在https://supermarket.chef.io上搜索build-essential,但我可能从评论中误解了您的实际问题。 - Tensibai
如果我没记错的话,build-essential cookbook 有一个属性可以在编译时运行,根据你的 chef-client 版本,chef_gem 资源默认情况下会在编译或收敛阶段运行。 - Tensibai
@Tensibai。感谢您对此事的帮助。不幸的是,在提交了一个Github问题之后,结果表明Chef计划永远不支持这个功能。以下是该问题的链接,以防谷歌的任何人找到这里:https://github.com/chef/chef/issues/6337 - user3505901
显示剩余4条评论
1个回答

0

首先尝试执行 xcode-select --install 命令。这可能是与 Xcode 构建系统有关的问题。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接