简体   繁体   中英

Ruby on Rails: How do I install json on Windows 7?

I installed Ruby on Rails using the Windows installer at http://railsinstaller.org . The installation went without any errors. However, when I tried:

rails new blog

I got the following error:

Installing json (1.6.5) with native extensions Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. C:/opt/Ruby_on_Rails/RailsInstaller/Ruby1.9.2/bin/ruby.exe extconf.rb An error occured while installing json (1.6.5), and Bundler cannot continue. Make sure that gem install json -v '1.6.5' succeeds before bundling.

Following the above suggestion, I ran:

gem install json -v '1.6.5'

This time, I got the following 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:/opt/Ruby_on_Rails/RailsInstaller/Ruby1.9.2/bin/ruby.exe extconf.rb

Would someone please advise on how I may be able to fix this error? Thank you.

You need to download the devkit and extract it to the bin path of your Ruby File (Eg: C:\\Ruby200\\bin). And then go to that directory from command prompt and type ruby dk.rb init and ruby dk.rb install . After that install the rails by gem install rails . After that check the gem list. Then you can see the json gem also.

Install the DevKit on RubyInstaller (http://rubyinstaller.org/add-ons/devkit/) then try again. I had the same issue last week.

I am having the same problem on my machine as well. To get around this problem I ran the devkitvars.bat (located in the devkit folder) through the cmd window and in the same command window ran the bundle install, it installed the gem with no problems.

This is an underlying issue on my machine where periodically it will fail to install new gems (all linked to a devkit path issue), I will have to get the time to investigate this properly, but the above solution should allow to install the gem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM