【问题标题】:bundle throwing error Gem::Installer::ExtensionBuildError: ERROR: with Mavericks and ruby 2.0捆绑抛出错误 Gem::Installer::ExtensionBuildError: ERROR: with Mavericks and ruby​​ 2.0
【发布时间】:2014-02-28 16:50:43
【问题描述】:

当我从 1.8.7 应用程序运行 bundle 时出现以下错误。我刚刚升级到 Mavericks 并且正在使用 rbenv。

我已经尝试过的事情:

1) 卸载并重新安装 rbenv 和 ruby​​-build

2) 删除目录并重新克隆

3) 使用xcode-select --install 安装x-code cli

4) brew install apple-gcc42

5) 删除根 ruby​​ 文件 (2.0) 并替换为 1.8

6) brew unlink apple-gcc42

以上方法均未奏效。

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for re.h... no
creating Makefile

make "DESTDIR="
compiling parser.c
parser.rl:165:20: error: expected '(' after 'if'
            if RTEST(rb_funcall(klass, i_json_creatable_p, 0)) {
               ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/ruby.h:445:18: note: expanded from macro 'RTEST'
#define RTEST(v) !(((VALUE)(v) & ~Qnil) == 0)
             ^
1 error generated.
make: *** [parser.o] Error 1


Gem files will remain installed in /Users/ryan/C2/c2/vendor/bundle/gems/json-1.4.6 for   inspection.
Results logged to /Users/ryan/C2/c2/vendor/bundle/gems/json-1.4.6/ext/json/ext/parser/gem_make.out
An error occurred while installing json (1.4.6), and Bundler cannot continue.
Make sure that `gem install json -v '1.4.6'` succeeds before bundling.

【问题讨论】:

    标签: ruby-on-rails ruby macos gcc osx-mavericks


    【解决方案1】:

    当我将一个旧的 Ruby 1.9.3 项目更改为 Ruby 2.2.0 并尝试 bundle 时,我得到了类似的东西。

    我收到了parser.rl:139:20: error: expected '(' after 'if'" and "accept.c:128:2: error: use of undeclared identifier 'TRAP_BEG' 之类的错误。

    修复方法是升级未能构建的 gems:在我的例子中是 bundle update json kgio,其中 json gem 和 kgio gem 未能构建。

    如果您在 Gemfile 中锁定了有问题的 gem 的版本,您可能也想解锁它们。例如。将 gem "json", "1.1.6" 更改为 gem "json"。虽然您当然应该确保自己知道为什么它首先被锁定。

    当您执行bundle 时,它会尝试安装/构建Gemfile.lock 中列出的gem 版本。在您的情况下,这些将是您之前在 Ruby 1.8.7 上安装的版本,在我的情况下是 1.9.3。我猜这些 gem 版本已经足够老了,它们根本无法为较新的 Ruby 编译。

    【讨论】:

    • 我刚刚使用 json gem 将 rubies 升级到 v2.0 时遇到了这个问题。 @Henrik N 的解决方案对我有用。我最初只是尝试bundle update 来尝试更新所有的宝石,但失败并出现错误。只为 json 运行包更新就可以了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-06
    • 2012-06-07
    • 1970-01-01
    相关资源
    最近更新 更多