gem install json -v 1.7.3 提示“请更新您的PATH以包含构建工具”

72

当我运行:

rails new blog

我得到:

Installing json (1.7.3)
Gem::InstallError: 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' and follow the instructions
at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'
An error occurred while installing json (1.7.3), and Bundler cannot continue.
Make sure that `gem install json -v '1.7.3'` succeeds before bundling.

当我运行:

gem install json -v 1.7.3

我得到:

Please update your PATH to include build tools or download the DevKit
from 'http://rubyinstaller.org/downloads' and follow the instructions
at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'

我正在使用Windows 8。在我的路径中确实有c:\ruby193\bin。我该怎么做来解决这些错误呢?

4个回答

208

确保安装 Devkit(勾选更新路径的复选框) : 您可能还需要重新安装 Ruby。

安装 DevKit

从此处下载 Development Kit http://rubyinstaller.org/downloads/

用于 Ruby 1.8.7 和 1.9.3 的 DevKit URL:DevKit-tdm-32-4.5.2

用于 Ruby 2.0 及以上版本(仅限 32 位版本): DevKit-mingw64-32-4.7.2

用于 Ruby 2.0 及以上版本(仅限 x64 - 64 位版本) DevKit-mingw64-64-4.7.2

按照 此处 的说明进行操作。

或使用简短说明:

解压 zip 文件

打开命令行并转到已解压缩的文件夹

ruby dk.rb init

ruby dk.rb install

gem install rdiscount --platform=ruby


3
对于链接 git clone git://github.com/oneclick/rubyinstaller.git,请点赞(+1)。 然后进入 rubyinstaller 目录,执行 rake devkit sfx=1 命令,这对我有用。 - Watt
1
谢谢,我点了个赞!在Windows 8.1 64位上使用Ruby 2.2 64位工作正常。 - Jay

4
有时候在运行ruby dk.rb init命令时会遇到如下错误:

Ruby Error

为了解决这个问题,需要更改命令提示符窗口的编码。 输入chcp 1256 你将收到以下消息:Active code page: 1256。

现在你可以顺利运行那个命令了。

祝好运。


3
如果您已经安装了正确的DevKit(例如:通过chocolatey),那么您只需要运行包含的脚本来设置环境变量即可。
在cmd中:
C:\> d:\path\to\DevKit2\devkitvars.bat

在PowerShell中:
PS> . d:\path\to\DevKit2\devkitvars.ps1

这些脚本将在当前命令窗口中设置正确的路径。

谢谢,我运行了 db.rb initinstall,但是我漏掉了这一步骤。 - Rafał Cieślak

1

在提取新的DevKit文件夹之前,请删除旧的文件夹,您可以从以下链接中根据您的配置下载新的文件夹:

此时的DevKit url供Ruby 1.8.7和1.9.3使用:https://github.com/downloads/oneclick/rubyinstaller/DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe

供Ruby 2.0及以上版本使用(仅限32位版本):http://dl.bintray.com/oneclick/rubyinstaller/DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe2

适用于 Ruby 2.0 及以上版本(仅限 x64 - 64 位)http://dl.bintray.com/oneclick/rubyinstaller/DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe3


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接