Problem installing ruby ​​gem json on my mac

I get this warning when I try to install the json module using ruby ​​stones.

Any ideas?

Mac-Mini poulh $ sudo gem install json

Password:

WARNING: the file '/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8 / specifications / json -1.2.0.gemspec "does not evaluate the gem specification

Create your own extensions. This may take some time...

ERROR: Error installing json:

ERROR: Failed to create native gem extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb install json mkmf.rb cannot find header files for ruby ​​in / System / Library / Frameworks / Ruby.framework / Versions /1.8/usr/lib/ruby/ruby.h

+6
json ruby rubygems macos
source share
3 answers

I think most Mac developers will recommend you run your own version of ruby ​​instead of the system version that comes with the Mac. This will give you more control over the versions and avoid environmental issues like the ones you are experiencing.

This is surprisingly easy to do with the Ruby Version Manager . You can install several versions of ruby ​​(1.8.6, 1.8.7, 1.9.1) and easily switch between them. As a side effect of using rvm, you no longer have to use sudo to set up gems.

+2
source share

I run Snow Leopard and have no problem installing a JSON pearl with my own version of ruby. It seems that this stone is collected from a source. Did you install the Xcode developer tools from the OS X drive?

+1
source share

I agree that you should install your own ruby ​​versions and tools for Xcode developers, but in a scenario where you want to make it work for people who don’t have these things, set the gemstone on json_pure, which is a purely ruby ​​implementation (so not the fastest, but super compatible).

Require 'json' will use it automatically.

+1
source share

All Articles