Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot install JSON gem in rails using windows

I am doing a bundle install and all of the gems work fine except JSON when it get to the JSON gem I receive this error.

Installing json (1.6.1) with native extensions c:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:55
    2:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::E
    xtensionBuildError)

            c:/Ruby192/bin/ruby.exe extconf.rb
    checking for re.h... *** extconf.rb failed ***
    Could not create Makefile due to some reason, probably lack of
    necessary libraries and/or headers.  Check the mkmf.log file for more
    details.  You may need configuration options.

Any idea on what could be causing this error?

like image 380
Ray A. Avatar asked Oct 15 '11 21:10

Ray A.


2 Answers

You are working with Windows, so the RubyInstaller Development Kit may help you: http://rubyinstaller.org/add-ons/devkit/

The devkit installs a C-compiler (and some other stuff) to compile C-written parts.

Install it and try again to install the gem - perhaps with option --platform=ruby.

Details can be found at https://github.com/oneclick/rubyinstaller/wiki/Development-Kit

like image 70
knut Avatar answered Oct 23 '22 21:10

knut


That's because this gem using a piece of code written on C. For working properly you need c compiler installed on your machine. As a way, try to use json_pure written on pure Ruby

like image 30
WarHog Avatar answered Oct 23 '22 20:10

WarHog