未知编码名称 - CP720 (ArgumentError) - 启动服务器时出现 ruby​​ on rails 错误

Ahl*_*ser 3 ruby ruby-on-rails ruby-on-rails-3 ruby-on-rails-4 ruby-on-rails-5

我的 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
Run Code Online (Sandbox Code Playgroud)

tec*_*ams 7

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

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

你的问题可以通过这个命令解决

chcp 1252
Run Code Online (Sandbox Code Playgroud)

更好的方法是不断地迫使终端通过使用批处理喜欢用正确的代码页,即

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