179

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?

tRuEsAtM
  • 3,517
  • 6
  • 43
  • 83
sridhar249
  • 4,471
  • 6
  • 26
  • 27

8 Answers8

354

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"
KyleMit
  • 30,350
  • 66
  • 462
  • 664
Massimo Fazzolari
  • 5,185
  • 3
  • 27
  • 36
  • 4
    Would like to add that you need to make sure whatever prompt you are using has admin rights or you will get errors during the install (win8 at least) – WSkid Mar 11 '12 at 13:46
  • Faced the same issue, tried the above steps and wow it worked fine !! +1 – peakit Apr 09 '12 at 12:56
  • 4
    Worked for me with //Ruby 1.9.3-p194// ... the "gotcha" appears to be that the DevKit must be a subdirectory of your Ruby directory... or maybe it's that your Ruby directory must be in the root of the drive. Phew, glad that's working. It's been driving me crazy for hours. – corlettk Apr 29 '12 at 03:20
  • 3
    Also worked for me, remember to put the DevKit folder in the ruby folder. Else it wont work. – Rails beginner May 07 '12 at 07:51
  • 1
    1.9.3 p0 is not longer there in downloads. Maybe you should mention that use any 1.9.3 (if it does work, that is). It worked for me. – Jus12 Jul 12 '13 at 06:17
  • One very important thing: after you install the DevKit make sure the path to it is included in the PATH environmental variable. Otherwise it won't work. – Alexander Popov Jul 18 '13 at 13:49
  • 4
    Works for Ruby 2.0 too. – CJBrew Nov 05 '13 at 13:47
  • One more note. The python has to be installed and be sure you have the path in PATH variable. – prespic May 30 '14 at 06:52
  • 1
    make sure the path in config.yaml is correct before you proceed to `ruby dk.rb review` and `ruby dk.rb install`. for me init auto discovered the ruby version coming with my Heroku install instead my 2.0.0 installed in a different location – Pavel 'PK' Kaminsky Jan 01 '15 at 12:12
  • 1
    This is much better and succinct than the official documentation. Working beautifully with Ruby 2.2 (32bits) – Matheus Felipe Oct 01 '15 at 22:12
  • Worked for ruby 2.0.x. Clear instructions and straight to the point – Marcello Grechi Lins Sep 16 '16 at 14:12
  • I installed using gem install devkit, is that method wrong? – Bhabani Sankar Mishra Apr 07 '17 at 12:47
56

I believe those installers make changes to the path. Did you try closing and re-opening the CMD window after running them and before the last attempt to install the gem that wants devkit present?

Also, be sure you are using the right devkit installer for your version of Ruby. The documentation at devkit wiki page has a requirements note saying:

For RubyInstaller versions 1.8.7, 1.9.2, and 1.9.3 use the DevKit 4.5.2

Chuck van der Linden
  • 6,660
  • 2
  • 28
  • 43
  • 3
    Hi Chuck van, I closed the CMD window and opened it again and ran the "gem install json". It did not help either. Still the same error as i mentioned in the question. I even tried installing ruby 1.9.2 on another Windows 2003 machine we have in our office, installed devkit and then tried "gem install json". I see the same problem. ("ERROR: Error installing json: The 'json' native gem requires installed build tools........."). Any other suggestions? Do you need more info from me? – sridhar249 Nov 15 '11 at 17:24
  • As i already mentioned in the question i am using "DevKit-4.5.0-20100819-1536-sfx.exe". I believe this is the correct devkit to use with Ruby1.9.2. – sridhar249 Nov 15 '11 at 17:32
  • 3
    did you follow all the instructions on this page? https://github.com/oneclick/rubyinstaller/wiki/Development-Kit. the devkit is a self extracting archive, if all you did was run the file you downloaded, you are only part way though installing it. – Chuck van der Linden Nov 15 '11 at 17:56
  • 5
    yes. I did follow all the instructions. Finally i got it working. I tried using "DevKit-tdm-32-4.5.2-20110712-1620-sfx.exe" instead of "DevKit-4.5.0-20100819-1536-sfx.exe" and it worked for me. Thanks for all your support Chuck Van. – sridhar249 Nov 15 '11 at 21:09
  • I followed the instructions, it worked for me. C:\DevKit>gem install json Temporarily enhancing PATH to include DevKit... Building native extensions. This could take a while... Successfully installed json-1.8.1 1 gem installed Installing ri documentation for json-1.8.1... Installing RDoc documentation for json-1.8.1... – ktang May 21 '14 at 10:57
10

I have found that the error is sometimes caused by a missing library.

so If you install RDOC first by running

gem install rdoc

then install rails with:

gem install rails

then go back and install the devtools as mentioned before with:

1) Extract DevKit to path C:\Ruby193\DevKit
2) cd C:\Ruby192\DevKit
3) ruby dk.rb init
4) ruby dk.rb review
5) ruby dk.rb install

then try installing json

which culminate with you finally being able to run

rails new project_name - without errors.

good luck

Aamir
  • 16,329
  • 10
  • 59
  • 65
8

Followed the steps.

  1. Extract DevKit to path C:\Ruby193\DevKit
  2. cd C:\Ruby192\DevKit
  3. ruby dk.rb init
  4. ruby dk.rb review
  5. ruby dk.rb install

Then I wrote the command

gem install rails -r -y
antyrat
  • 27,479
  • 9
  • 75
  • 76
7

1) Download Ruby 1.9.3

2) cmd check command: ruby -v 'return result ruby 1.9.3 then success full install ruby

3) Download DevKit file from http://rubyinstaller.org/downloads (DevKit-tdm-32-4.5.2-20110712-1620-sfx.exe)

4) Extract DevKit to path C:\Ruby193\DevKit

5) cd C:\Ruby193\DevKit

6) ruby dk.rb init

7) ruby dk.rb review

8) ruby dk.rb install

9) cmd : gem install rails -v3.1.1 'few time installing full process'

10) cmd : rails -v 'return result rails 3.1.1 then its success fully install'

enjoy Ruby on Rails...

Aamir
  • 16,329
  • 10
  • 59
  • 65
Ravi Parsania
  • 715
  • 7
  • 11
5

I would like to add that you should make sure that the generated config.yml file when doing ruby dk.rb init contains the path to the ruby installation you want to use DevKit with. In my case, I had the Heroku Toolbelt installed on my system, which provided its own ruby installation, located at a different place. The config.yml file used that particular installation, and that's not what I wanted. I had to manually edit the file to point it to the correct one, then continue with ruby dk.rb review, etc.

marco-fiset
  • 1,933
  • 1
  • 19
  • 31
1

My solution is simplier and checked on Ruby 2.0. It also enable download Json. (run CMD.exe as administrator)

    C:\RubyDev>devkitvars.bat
    Adding the DevKit to PATH...

And then write again gem command.

Artur_PL
  • 57
  • 1
  • 7
1

My gem version 2.0.3 and I was getting the same issue. This command resolved it:

gem install json --platform=ruby --verbose
Aamir
  • 16,329
  • 10
  • 59
  • 65
Chitresh goyal
  • 313
  • 1
  • 7