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

懵懂的女人 提交于 2019-12-06 02:25:04

问题


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.


回答1:


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




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/8884267/ruby-on-rails-how-do-i-install-json-on-windows-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!