ruby-on-rails - 无法在 Mac OS X 10.8.4 上安装 json 1.8 gem

标签 ruby-on-rails ruby rubygems

我正在尝试在第二台计算机上安装我的 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.

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

我使用 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 进行安装不会改变任何内容。

我卸载并重新安装了自制软件、rvm、ruby 和命令行工具,但没有任何帮助。

更新

/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 -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 与 ruby​​ 一起安装了 json 1.7.7

更新 3

似乎我的机器在所有 native 扩展上都失败了。 gem install bcrypt-ruby 给出相同的错误信息。

最佳答案

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

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

关于ruby-on-rails - 无法在 Mac OS X 10.8.4 上安装 json 1.8 gem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17322583/

相关文章:

ruby - Rspec 测试 : it { should respond_to() }

ruby-on-rails - 在 rails 中相交列表的最快方法?

ruby - 正则表达式的问题

javascript - 剪辑网页*内容*的可靠方法是什么?

Ruby 等价于 unix 中的查找

Ruby Gem 在 Mavericks 和 Xcode 5.1 上安装 Json 失败 - 未知参数 : '-multiply_definedsuppress'

ruby-on-rails - 如何在 Devise 中填充一些默认用户?

ruby-on-rails - Rails button_to-将CSS类应用于按钮

ruby-on-rails - 根据 Rails 中的环境设置配置常量

ruby-on-rails - 数组连接函数 - Ruby on Rails