I wanted to install the rspec-rails gem with ruby 1.9.3 on windows 7. I got some errors saying that some json libraries could not be installed. So, I used the instructions below to solve it. Source = The 'json' native gem requires installed build tools
- Download [Ruby 1.9.3][2] from [rubyinstaller.org][3]
- Download DevKit file from [rubyinstaller.org][3]
- For Ruby 1.9.3 use [DevKit-tdm-32-4.5.2-20110712-1620-sfx.exe][4]
- Extract DevKit to path C:\Ruby193\DevKit
- Run
cd C:\Ruby193\DevKit
- Run
ruby dk.rb init
- Run
ruby dk.rb review
- 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"
When I execute the above first step, I get the error -
C:\Ruby193\DevKit>gem install json --platform=ruby
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
C:/Ruby193/bin/ruby.exe extconf.rb
creating Makefile
make
'make' is not recognized as an internal or external command,
operable program or batch file.
Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1 for inspection. Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
I am trying to solve the above error now -
'make' is not recognized as an internal or external command, operable program or batch file.
using make is not recognized as an internal or external command - Qt SDK - Windows
If someone already knows how to fix this, then please help me. I have been struggling to install gems and I am failing for so many days. I am wondering if ruby is so difficult.
The DOSKEY approach failed !!!
I did this - Install Mingw and installed all its developer tools and base stuff. Then added C:\MinGW\bin to environment variables to find mingw32-make.exe. Then, I ran the DOSKEY make=mingw32-make
followed by the ruby command. I got the same error. I am guessing that the ruby code is spawning off a hidden cmd window and thats why the command is not working. DOSKEY is valid only in the cmd window in which you run it.
Next step - Not so nice, but, I'll change mingw32-make.exe
to make.exe and see.
Failed again with a new error -
Temporarily enhancing PATH to include DevKit... Building native extensions. This could take a while... ERROR: Error installing json: ERROR: Failed to build gem native extension.
C:/Ruby193/bin/ruby.exe extconf.rb creating Makefile
make generating generator-i386-mingw32.def compiling generator.c In file included from generator.c:1:0: ../fbuffer/fbuffer.h:5:18: fatal error: ruby.h: No such file or directory #include "ruby.h" ^ compilation terminated. Makefile:204: recipe for target 'generator.o' failed make: *** [generator.o] Error 1
Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1 for inspection. Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
What do I do now ?