Home Can't install json with gem
Reply: 3

Can't install json with gem

katsuya Published in 2011-03-22 21:53:01Z

I have tried following command in terminal (OSX 10.6.6) and end up with an error. Does anyone know how to solve this?

sudo gem install json 

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

        /usr/local/bin/ruby extconf.rb
checking for ruby/re.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
/usr/local/lib/ruby/1.9.1/mkmf.rb:368:in `try_do': The complier failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /usr/local/lib/ruby/1.9.1/mkmf.rb:452:in `try_cpp'
    from /usr/local/lib/ruby/1.9.1/mkmf.rb:834:in `block in have_header'
    from /usr/local/lib/ruby/1.9.1/mkmf.rb:693:in `block in checking_for'
    from /usr/local/lib/ruby/1.9.1/mkmf.rb:280:in `block (2 levels) in postpone'
    from /usr/local/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /usr/local/lib/ruby/1.9.1/mkmf.rb:280:in `block in postpone'
    from /usr/local/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /usr/local/lib/ruby/1.9.1/mkmf.rb:276:in `postpone'
    from /usr/local/lib/ruby/1.9.1/mkmf.rb:692:in `checking_for'
    from /usr/local/lib/ruby/1.9.1/mkmf.rb:833:in `have_header'
    from extconf.rb:17:in `'

Gem files will remain installed in /usr/local/lib/ruby/gems/1.9.1/gems/json-1.5.1 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.9.1/gems/json-1.5.1/ext/json/ext/generator/gem_make.out
Shiv Reply to 2011-03-22 22:01:59Z

You will need to install XCode. It is available on the AppStore

If XCode is installed and you are still getting this error, maybe you should try using rvm

Community Reply to 2017-05-23 10:28:25Z

The reason you're getting this error is because the json gem includes C/C++ extensions that need to be compiled on your machine before they can run.

Just installing XCode won't fix it, you need to specifically install the XCode Command Line Tools. It's a compiler/linker toolchain including C/C++ compilers, make, etc.

There's an option to install them within a menu inside the XCode GUI, see this thread for details:

Xcode 4.4 and later install Command Line Tools

chad_ Reply to 2015-05-22 18:39:53Z

You should be able to get the necessary tools installed by running:

> xcode-select --install
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.307887 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO