Amazon EC2 - Gem :: Installer :: ExtensionBuildError:错误:无法构建gem原生扩展。 (JSON)

时间:2013-10-23 11:52:10

标签: ruby-on-rails ruby json amazon-ec2 bundle

我刚刚部署了一些新代码(视图中只有一些文本更新),在处理命令 cap deploy 时,我收到以下错误消息:

 ** [out :: IP] Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
 ** [out :: IP]
 ** [out :: IP] /usr/local/bin/ruby extconf.rb
 ** [out :: IP] creating Makefile
 ** [out :: IP]
 ** [out :: IP] make "DESTDIR="
 ** [out :: IP]
 ** [out :: IP] Gem files will remain installed in /home/deployer/fileto/shared/bundle/ruby/2.0.0/gems/json-1.8.1 for inspection.
 ** [out :: IP] Results logged to /home/deployer/appname/shared/bundle/ruby/2.0.0/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
 ** [out :: IP] An error occurred while installing json (1.8.1), and Bundler cannot continue.
 ** [out :: IP] Make sure that `gem install json -v '1.8.1'` succeeds before bundling.

它刚出现在今天,我没有对该应用做任何事情,为期2周。我已经尝试将 json gem添加到Gemfile中,但它没有帮助 - 仍然是同样的错误。

有什么问题?

谢谢

5 个答案:

答案 0 :(得分:3)

迟到的回答,但自从我来到Google以后,其他人也可能会这样:

您需要重新安装命令行工具。我假设你升级为小牛队?它从xcode中删除了CLI。您现在必须实际访问Apple开发人员站点并下载适用于Mavericks的CL Tool: https://developer.apple.com/downloads/index.action?name=for%20Xcode%20-#

安装后,捆绑应该可以工作。

答案 1 :(得分:0)

据我所知。这件事可能由于不同的原因而发生,

1) The gem version you are using or their dependency are not supported with other gem version or the ruby version you are using.
2) there is not enough permission to install the gem
3) the gem version is not present in the repository.

对不起,我无法给你确切的解决方案,但你可以检查这个选项并尝试相应的。

答案 2 :(得分:0)

这是EC2的发展之谜。

我通过登录EC2服务器解决了这个问题,并按照以下命令运行:

sudo gem install json

之后我能够正确部署应用程序。但是,我仍然不明白为什么或从哪里发生这个问题。

答案 3 :(得分:0)

我遇到了同样的问题,也许它可能是JSON gem的新版本。我将此行添加到我的Gemfile中:

gem 'json', '1.8.0' 

(JSON gem的PREVIOUS版本)

然后运行:bundle update以覆盖较新版本的JSON gem。

我不知道更新版本的宝石的问题是什么,但它在10月17日发布,如果你之前没有遇到过这个问题,也许它是更新后的宝石......?

答案 4 :(得分:0)

如果您正在运行RVM,那么除了为Mavericks安装命令行工具之外,如@ mike-manfrin提供的答案,您可能还需要执行以下操作:

  • 更新RVM

rvm get latest

  • 重新安装项目或gemset正在使用的ruby

rvm reinstall <ruby-version>

如果您不确定当前正在使用哪种红宝石,请使用rvm list。在这两个步骤之后,我发现我可以捆绑项目并正确安装了json gem。