2

我已经在我的电脑上安装了 Ruby 1.92,并且想安装 rails。

当我运行:gem install rails时,我收到如下错误消息:

*D:\Ruby192\Devkit>gem install rails
*ERROR:  Error installing rails:
        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'**

然后我下载 DevKit 4.5.2 或 DevKit 3.5 并尝试它们:

D:\Ruby192\Devkit>ruby dk.rb init

我总是收到错误消息:

d:/Ruby192/lib/ruby/1.9.1/win32/registry.rb:175:in `tr': invalid byte sequence in UTF-8 (ArgumentError)
        from d:/Ruby192/lib/ruby/1.9.1/win32/registry.rb:175:in `initialize'
        from d:/Ruby192/lib/ruby/1.9.1/win32/registry.rb:233:in `exception'
        from d:/Ruby192/lib/ruby/1.9.1/win32/registry.rb:233:in `raise'
        from d:/Ruby192/lib/ruby/1.9.1/win32/registry.rb:233:in `check'
        from d:/Ruby192/lib/ruby/1.9.1/win32/registry.rb:256:in `OpenKey'
        from d:/Ruby192/lib/ruby/1.9.1/win32/registry.rb:387:in `open'
        from d:/Ruby192/lib/ruby/1.9.1/win32/registry.rb:498:in `open'
        from dk.rb:118:in `block in scan_for'
        from dk.rb:116:in `each'
        from dk.rb:116:in `scan_for'
        from dk.rb:138:in `block in installed_rubies'
        from dk.rb:138:in `collect'
        from dk.rb:138:in `installed_rubies'
        from dk.rb:146:in `init'
        from dk.rb:313:in `run'
        from dk.rb:332:in `<main>'

大家对这个问题有什么建议吗?</p>

4

2 回答 2

1

我也遇到过同样的情况。我认为您可能想要安装json库。您应该在此终端上使用msys.bat和安装。json

  1. msys.bat在 DevKit 目录中执行 -> 它调用一个新终端。
  2. gem install json在这个终端上。
  3. 你可以继续gem install rails
于 2012-06-13T02:27:10.487 回答
1

LANG通过首先清除环境变量为我解决了这个问题:

set LANG=
ruby dk.rb init

这个想法来自RubyInstaller Google Group 上的这个问题

于 2013-10-20T19:40:08.403 回答