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

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