[英]Can't install json 1.8 gem on Mac OS X 10.8.4
我正在嘗試在第二台計算機上安裝我的rails應用程序。 但是當我運行bundle install
我得到了json gem的錯誤:
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.
該計算機使用Xcode 4.6.3和最新的命令行工具運行Mac OS X 10.8.4。
我使用rvm安裝了最新的ruby:
$ rvm -v
rvm 1.21.2 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [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 gem時,我得到幾乎相同的錯誤:
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
進行安裝不會改變任何東西。
我卸載並重新安裝了homebrew,rvm,ruby和命令行工具,但沒有任何幫助。
更新
/Users/feuerball/.rvm/gems/ruby-2.0.0-p195/gems/json-1.8.0/ext/json/ext/generator/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,Command Line Tools,Homebrew,rvm和Ruby。 Ruby現在已經是補丁級別247,該死的問題仍然存在。 多么浪費時間......如果重要的話:rvm和ruby一起安裝了json 1.7.7
更新3
似乎我的機器在所有原生擴展上都失敗了。 gem install bcrypt-ruby
給出了相同的錯誤消息。
問題是我的主文件夾位於一個單獨的卷上,其名稱中包含一個空格。 由於空間,名稱的第二部分被解釋為一個選項。 卷名稱類似於My Data
,因此我得到了消息invalid option -D
。
我剛剛重命名了這個卷,現在一切安裝都很好。
這似乎發生在Json版本1.8.0和1.8.1(Ruby 2.2.3)......我能夠毫無問題地升級到1.8.2和1.8.3 ......指定這些版本
gem 'json', '~> 1.8.2'
在我的捆綁讓我解決了這個問題。
這似乎仍然是一個錯誤... https://github.com/flori/json/issues/163
只有捆綁造成的。 你能嘗試一下gem install json嗎? 它可能會在以后解決問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.