我收到错误信息:在'tr':运行时UTF-8(ArgumentError)中的无效字节序列:ruby dk.rb init

时间:2012-05-14 01:33:03

标签: ruby-on-rails ruby json utf-8 tr

我已经在我的计算机上安装了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>'

你们对这个问题有什么建议吗?

2 个答案:

答案 0 :(得分:1)

我遇到了同样的情况。我想你可能想要安装json库。您应该使用msys.bat并在此终端上安装json

  1. 在DevKit目录中执行msys.bat - &gt;它会调用一个新的终端。
  2. gem install json在这个终端上。
  3. 您可以继续gem install rails

答案 1 :(得分:1)

通过首先清除LANG环境变量来解决问题:

set LANG=
ruby dk.rb init

这个想法来自this question on the RubyInstaller Google Group