2013-06-26 209 views
3

我试图在第二台计算机上安装我的rails应用程序。但是,当我运行bundle install我得到一个错误使用JSON宝石:无法在Mac OS X上安装json 1.8 gem 10.8.4

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

    /Users/feuerball/.rvm/rubies/ruby-2.0.0-p195/bin/ruby extconf.rb 
/Users/feuerball/.rvm/rubies/ruby-2.0.0-p195/bin/ruby: invalid option -D (-h will show valid options) (RuntimeError) 


Gem files will remain installed in /Users/feuerball/.rvm/gems/ruby-2.0.0-p195/gems/json-1.8.0 for inspection. 
Results logged to /Users/feuerball/.rvm/gems/ruby-2.0.0-p195/gems/json-1.8.0/ext/json/ext/generator/gem_make.out 

An error occurred while installing json (1.8.0), and Bundler cannot continue. 
Make sure that `gem install json -v '1.8.0'` succeeds before bundling. 

计算机运行的Mac OS X 10.8.4和Xcode 4.6.3和最新的命令行工具。

$ rvm -v 

rvm 1.21.2 (stable) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/] 

$ ruby -v 
ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-darwin12.4.0] 
$ gem -v 
2.0.3 

当我尝试使用gem install json安装JSON宝石,我得到几乎相同的错误:

Building native extensions. This could take a while... 
ERROR: Error installing json: 
    ERROR: Failed to build gem native extension. 

    /Users/feuerball/.rvm/rubies/ruby-2.0.0-p195/bin/ruby extconf.rb 
/Users/feuerball/.rvm/rubies/ruby-2.0.0-p195/bin/ruby: invalid option -D (-h will show valid options) (RuntimeError) 


Gem files will remain installed in /Users/feuerball/.rvm/gems/ruby-2.0.0-p195/gems/json-1.8.0 for inspection. 
Results logged to /Users/feuerball/.rvm/gems/ruby-2.0.0-p195/gems/json-1.8.0/ext/json/ext/generator/gem_make.out 

尝试使用sudo没有安装

我用RVM安装了最新的红宝石改变一切。

我卸载并重新安装了自制软件,rvm,ruby &命令行工具,但没有什么帮助。

更新

Contentent的/Users/feuerball/.rvm/gems/ruby-2.0.0-p195/gems/json-1.8.0/ext/json/ext/generato‌​r/gem_make.out

/Users/feuerball/.rvm/rubies/ruby-2.0.0-p195/bin/ruby extconf.rb 
/Users/feuerball/.rvm/rubies/ruby-2.0.0-p195/bin/ruby: invalid option -D (-h will show valid options) (RuntimeError) 

GCC版本:

$ gcc -v 
Using built-in specs. 
Target: i686-apple-darwin11 
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.11~182/src/configure --disable-checking --enable-werror --prefix=/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.11~182/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1 
Thread model: posix 
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00) 

更新2

我做全新安装的OS X,Xcode,命令行工具,Homebrew,rvm和Ruby。 Ruby现在是修补程序级别247,该死的问题仍然存在。什么是浪费时间......如果是重要的:RVM安装JSON 1.7.7加上红宝石

更新3

看来,我的机器上的所有原生扩展失败。 gem install bcrypt-ruby给出相同的错误信息。

+0

您可以要求/Users/feuerball/.rvm/gems/ruby-2.0.0-p195/gems/json-1.8.0/ext/json/ext/generator/gem_make.out的内容 – Remear

+0

因为它包含只有2行,我把它插入到原文中。 – stevecross

+0

这一次让我目前有些失落。我和你的设置完全一样,并且json gem安装没有问题。 rvm 1.21.2,gem 2.0.3,ruby 2.0.0p195(2013-05-14修订版40734)[x86_64-darwin12.3.0]。你机器上的gcc -v的输出是什么? – Remear

回答

6

问题是我的主文件夹位于名称中包含空格的单独卷上。由于这个空间,名字的第二部分被解释为一个选项。卷的名称是类似于My Data,因此我收到了消息invalid option -D

我刚刚重命名了这个卷,现在一切安装正常。

+0

同样的问题在这里......谢谢! –

+1

同样的问题。基本上捆绑无法处理路径名称中的空间导致错误的参数解析。如耻辱。 – kureikain

-1

这似乎仍然是一个错误...... https://github.com/flori/json/issues/163

只有捆绑造成的。 你可以试试gem install json吗? 它可能会解决后面的问题。

+0

正如我写的'gem install json'也不起作用。另外'sudo'不会改变任何东西。 – stevecross

+3

仅供参考,从不使用rdo的sudo。 – Remear

1

这似乎与Json版本1.8.0和1.8.1(Ruby 2.2.3)发生......我能够升级到1.8.2和1.8.3,没有问题......指定这些版本

gem 'json', '~> 1.8.2' 

在我的包中让我解决了这个问题。

+0

这并不能解决问题,因为它不是由json gem引起的。 – stevecross

相关问题