未知编码名称 - CP720(ArgumentError)- 在启动服务器时出现Ruby on Rails错误

3

我的rails应用启动时出现此错误。这可能是什么原因导致的?

c:\test_install>rails server
C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/win32/registry.rb:70:in `find': unkno
wn encoding name - CP720 (ArgumentError)
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/win32/registry.rb:70:in
`<module:Win32>'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/win32/registry.rb:3:in `
<top (required)>'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/rubygems/core_ext/kernel
_require.rb:55:in `require'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/rubygems/core_ext/kernel
_require.rb:55:in `require'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/win32/resolv.rb:6:in `<t
op (required)>'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/rubygems/core_ext/kernel
_require.rb:55:in `require'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/rubygems/core_ext/kernel
_require.rb:55:in `require'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/resolv.rb:170:in `<class
:Hosts>'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/resolv.rb:167:in `<class
:Resolv>'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/resolv.rb:37:in `<top (r
equired)>'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/rubygems/core_ext/kernel
_require.rb:55:in `require'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/rubygems/core_ext/kernel
_require.rb:55:in `require'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/rubygems/remote_fetcher.
rb:5:in `<top (required)>'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/rubygems/core_ext/kernel
_require.rb:55:in `require'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/rubygems/core_ext/kernel
_require.rb:55:in `require'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.12.0
.pre.1/lib/bundler/gem_remote_fetcher.rb:2:in `<top (required)>'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/rubygems/core_ext/kernel
_require.rb:55:in `require'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/rubygems/core_ext/kernel
_require.rb:55:in `require'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.12.0
.pre.1/lib/bundler.rb:7:in `<top (required)>'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/rubygems/core_ext/kernel
_require.rb:55:in `require'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/rubygems/core_ext/kernel
_require.rb:55:in `require'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.12.0
.pre.1/lib/bundler/setup.rb:5:in `<top (required)>'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/rubygems/core_ext/kernel
_require.rb:135:in `require'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/rubygems/core_ext/kernel
_require.rb:135:in `rescue in require'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/rubygems/core_ext/kernel
_require.rb:144:in `require'
        from c:/test_install/config/boot.rb:3:in `<top (required)>'
        from bin/rails:3:in `require_relative'
        from bin/rails:3:in `<main>'
c:\test_install>gem install rails

你是否已经安装了Ruby DevKit - MarsAtomic
Rails 的版本是什么? - pixelearth
在创建新文件并尝试运行(rails server)后,我无法获取URL。 - Ahlam Ahmad Alnaser
Rails 4.2.5.1 版本 - Ahlam Ahmad Alnaser
2
这将是你遇到的许多与Windows相关的问题中的第一个。最好从头开始,安装一个虚拟化环境(Vagrant + Virtualbox)。 - MarsAtomic
1个回答

7

代码页720是MS-DOS使用的阿拉伯语字符。

建议您将终端代码页切换为Ruby所理解的内容,例如拉丁字母的Windows 1252字符编码。

您可以通过此命令解决问题。

chcp 1252

更好的方法是永久强制终端使用正确的代码页,即使用类似这个批处理文件。

此外,对于 Ruby on Rails 开发人员,最好使用带有 rvmrbenv 的 Linux。


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