The 'json' native gem requires installed build tools

sridhar249 picture sridhar249 · Nov 11, 2011 · Viewed 127.8k times · Source

I have ruby 1.9.2p180 (2011-02-18) [i386-mingw32] installed on my windows 7 machine. Now I tried to install the JSON gem using the command, "gem install json" and got the following error.

ERROR:  Error installing JSON:
    The 'json' native gem requires installed build tools.

Please update your PATH to include build tools or download the DevKit
from '[http://rubyinstaller.org/downloads][1]' and follow the instructions
at '[http://github.com/oneclick/rubyinstaller/wiki/Development-Kit][2]'

Then I went and downloaded DevKit-4.5.0-20100819-1536-sfx.exe. Extracted it to C:\DevKit. And then from the command prompt, I executed the following commands.

ruby dk.rb init

After the above command is executed, I verified that config.yaml is generated and it has the path for my ruby folder added automatically. This is the line at the bottom of the config.yaml file "- C:/Ruby192"

ruby dk.rb review

I got the message that devkit functionality will be injected into the rubies when you run "ruby dk.rb install"

ruby dk.rb install

I got the following message.

[INFO] RubyGems override already in place for C:/Ruby192, skipping.
[INFO] Installing C:/Ruby192/lib/ruby/site_ruby/devkit.rb

Now I tried executing the JSON gem again using the command gem install json. Then got the same error message as before.

ERROR:  Error installing JSON:
    The 'json' native gem requires installed build tools.........

Am I missing something?

Answer

Massimo Fazzolari picture Massimo Fazzolari · Dec 11, 2011

Follow the Instructions from the Ruby Installer Developer Kit Wiki:

  1. Download Ruby 1.9.3 from rubyinstaller.org
  2. Download DevKit file from rubyinstaller.org
  3. Extract DevKit to path C:\Ruby193\DevKit
  4. Run cd C:\Ruby193\DevKit
  5. Run ruby dk.rb init
  6. Run ruby dk.rb review
  7. Run ruby dk.rb install

To return to the problem at hand, you should be able to install JSON (or otherwise test that your DevKit successfully installed) by running the following commands which will perform an install of the JSON gem and then use it:

gem install json --platform=ruby
ruby -rubygems -e "require 'json'; puts JSON.load('[42]').inspect"