Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When I try sudo gem install json I get the following error

With Mavericks, you can solve this problem by installing the Xcode Command Line Tools from the command line like this:

xcode-select --install

Update: Don't forget to accept the license agreement after you install or update:

sudo xcodebuild -license


If you have this problem:

ERROR:  Error installing json:
ERROR: Failed to build gem native extension.

and you are using a Mac with OS X (tested with 10.8.1 Mountain Lion), you need to download Xcode from the Mac App Store (or from developer.apple.com if you have a dev account - it's free BTW and you can download a DMG installer)

The latest Xcode versions (I'm using Xcode 4.4.1) does NOT include command line tools. Now you need to install this additional package inside Xcode. Once done, your problem is fixed.

To do that, open Xcode, go to Preferences > Downloads > Components. Install "Command Line Tools". You're done. Now you can install the json Ruby gem.

enter image description here


You are missing the ruby development headers. To install these on an OS like ubuntu you should use:

aptitude install ruby1.8-dev

The ruby headers don’t come installed with the base ruby install with Mac OS X. These can been found on Mac OS X Install Disc 2 by installing the XCode Tools.

Once installed, all was well!

UPDATE As of at least OS X 10.7.3 this is no longer a problem, it "just works"

MacBook-Pro:tmp$ sudo gem install json
Password:
Building native extensions.  This could take a while...
Successfully installed json-1.6.5
1 gem installed
Installing ri documentation for json-1.6.5...
Installing RDoc documentation for json-1.6.5...
MacBook-Pro:tmp$ uname -a