“json”原生 gem 需要安装构建工具
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8100891/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The 'json' native gem requires installed build tools
提问by sridhar249
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.
我已经ruby 1.9.2p180 (2011-02-18) [i386-mingw32]安装在我的 Windows 7 机器上。现在我尝试使用命令“gem install json”安装 JSON gem 并收到以下错误。
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.
然后我去下载了 DevKit-4.5.0-20100819-1536-sfx.exe。将其解压缩到 C:\DevKit。然后在命令提示符下,我执行了以下命令。
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"
执行上述命令后,我验证了 config.yaml 已生成并自动添加了我的 ruby 文件夹的路径。这是 config.yaml 文件底部的行“-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”时,devkit 功能将被注入到 rubies 中
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.
现在我尝试使用命令再次执行 JSON gem gem install json。然后得到和以前一样的错误信息。
ERROR: Error installing JSON:
The 'json' native gem requires installed build tools.........
Am I missing something?
我错过了什么吗?
采纳答案by Chuck van der Linden
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?
我相信那些安装程序会更改路径。在运行 CMD 窗口之后以及最后一次尝试安装需要 devkit 的 gem 之前,您是否尝试关闭并重新打开它们?
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:
此外,请确保您使用的是适合您的 Ruby 版本的正确 devkit 安装程序。devkit wiki 页面上的文档有一个要求说明:
For RubyInstaller versions 1.8.7, 1.9.2, and 1.9.3 use the DevKit 4.5.2
对于 RubyInstaller 版本 1.8.7、1.9.2 和 1.9.3,请使用 DevKit 4.5.2
回答by Massimo Fazzolari
Follow the Instructions from the Ruby Installer Developer Kit Wiki:
按照Ruby Installer Developer Kit Wiki 中的说明进行操作:
- Download Ruby 1.9.3from rubyinstaller.org
- Download DevKit file from rubyinstaller.org
- For Ruby 1.9.3 use DevKit-tdm-32-4.5.2-20110712-1620-sfx.exe
- 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
- 从rubyinstaller.org下载Ruby 1.9.3
- 从rubyinstaller.org下载 DevKit 文件
- 对于 Ruby 1.9.3 使用DevKit-tdm-32-4.5.2-20110712-1620-sfx.exe
- 将 DevKit 解压到路径 C:\Ruby193\DevKit
- 跑
cd C:\Ruby193\DevKit - 跑
ruby dk.rb init - 跑
ruby dk.rb review - 跑
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:
回到手头的问题,您应该能够通过运行以下命令来安装 JSON(或以其他方式测试您的 DevKit 是否成功安装),该命令将执行 JSON gem 的安装,然后使用它:
gem install json --platform=ruby
ruby -rubygems -e "require 'json'; puts JSON.load('[42]').inspect"
回答by Phineas Dashevsky
I have found that the error is sometimes caused by a missing library.
我发现错误有时是由缺少库引起的。
so If you install RDOC first by running
所以如果您首先通过运行安装 RDOC
gem install rdoc
gem 安装 rdoc
then install rails with:
然后安装导轨:
gem install rails
宝石安装导轨
then go back and install the devtools as mentioned before with:
然后返回并安装前面提到的 devtools:
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
1) 将 DevKit 提取到路径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
然后尝试安装json
which culminate with you finally being able to run
最终你终于可以跑步了
rails new project_name- without errors.
rails new project_name- 没有错误。
good luck
祝你好运
回答by Evangelos Alimpertis
Followed the steps.
按照步骤操作。
- Extract
DevKitto pathC:\Ruby193\DevKit cd C:\Ruby192\DevKitruby dk.rb initruby dk.rb reviewruby dk.rb install
- 提取
DevKit到路径C:\Ruby193\DevKit cd C:\Ruby192\DevKitruby dk.rb initruby dk.rb reviewruby dk.rb install
Then I wrote the command
然后我写了命令
gem install rails -r -y
回答by Ravi Parsania
1) Download Ruby 1.9.3
1) 下载 Ruby 1.9.3
2) cmd check command: ruby -v'return result ruby 1.9.3 then success full install ruby
2) cmd check 命令: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)
3) 从http://rubyinstaller.org/downloads下载 DevKit 文件(DevKit-tdm-32-4.5.2-20110712-1620-sfx.exe)
4) Extract DevKit to path C:\Ruby193\DevKit
4) 将 DevKit 解压到路径 C:\Ruby193\DevKit
5) cd C:\Ruby193\DevKit
5) cd C:\Ruby193\DevKit
6) ruby dk.rb init
6) ruby dk.rb init
7) ruby dk.rb review
7) ruby dk.rb review
8) ruby dk.rb install
8) ruby dk.rb install
9) cmd : gem install rails -v3.1.1'few time installing full process'
9) cmd : gem install rails -v3.1.1'很少有时间安装完整过程'
10) cmd : rails -v'return result rails 3.1.1 then its success fully install'
10) cmd : rails -v'返回结果 rails 3.1.1 然后它的成功完全安装'
enjoy Ruby on Rails...
享受 Ruby on Rails...
回答by marco-fiset
I would like to add that you should make sure that the generated config.ymlfile when doing ruby dk.rb initcontains 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.ymlfile 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.
我想补充一点,您应该确保config.yml在执行时生成的文件ruby dk.rb init包含要使用 DevKit 的 ruby 安装路径。就我而言,我在我的系统上安装了 Heroku Toolbelt,它提供了自己的 ruby 安装,位于不同的地方。该config.yml文件使用了该特定安装,这不是我想要的。我必须手动编辑该文件以将其指向正确的文件,然后继续使用ruby dk.rb review,等等。
回答by Artur_PL
My solution is simplier and checked on Ruby 2.0. It also enable download Json. (run CMD.exe as administrator)
我的解决方案更简单,并在 Ruby 2.0 上进行了检查。它还允许下载 Json。(以管理员身份运行 CMD.exe)
C:\RubyDev>devkitvars.bat
Adding the DevKit to PATH...
And then write again gem command.
然后再写gem命令。
回答by Chitresh goyal
My gem version 2.0.3 and I was getting the same issue. This command resolved it:
我的 gem 版本 2.0.3 和我遇到了同样的问题。这个命令解决了它:
gem install json --platform=ruby --verbose

