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/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 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.
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 message invalid option -D
.
I just renamed this volume and now everything installs fine.
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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.