Can't install json 1.8 gem on Mac OS X 10.8.4

ぃ、小莉子 提交于 2019-12-10 19:08:09

问题


I'm trying to to install my rails app on a second computer. But when I run bundle install I get an error with the 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.

The computer runs Mac OS X 10.8.4 with Xcode 4.6.3 and the latest command line tools.

I installed the latest ruby using rvm:

$ 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

When I try to install the json gem using gem install json I get almost the same error:

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

Trying to install using sudo does not change anything.

I uninstalled and reinstalled homebrew, rvm, ruby & the command line tools but nothing helps.

Update

Contentent of /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 Version:

$ 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)

Update 2

I did a fresh install of OS X, Xcode, Command Line Tools, Homebrew, rvm and Ruby. Ruby is now patch level 247 and the damn problem is still there. What a waste of time... If it is important: rvm installed json 1.7.7 together with ruby

Update 3

Seems that my machine fails on all native extensions. gem install bcrypt-ruby gives the same error message.


回答1:


The problem was that my home folder is on a separate volume which contained a space in its name. Because of the space the second part of the name was interpreted as an option. The volumes name was something like My Data and thus I got the messageinvalid option -D.

I just renamed this volume and now everything installs fine.




回答2:


This seemed to happen with Json versions 1.8.0 and 1.8.1 (Ruby 2.2.3) ... I was able to upgrade to 1.8.2 and 1.8.3 with no problems ... specifying those versions

gem 'json', '~> 1.8.2'

in my bundle got me around the problem.




回答3:


This seems to still be a bug... https://github.com/flori/json/issues/163

Only caused with bundle. Can you try the gem install json? It might solve the problem after.



来源:https://stackoverflow.com/questions/17322583/cant-install-json-1-8-gem-on-mac-os-x-10-8-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!