我需要设置环境以开始在Windows 8上编写黄瓜测试。我安装了ruby 2.1.5(来自ruby-lang.org上的windows安装程序)。 但是当我想安装宝石时,我遇到了编码问题而陷入困境。
ERROR: While executing gem ... (Encoding::CompatibilityError)
incompatible character encodings: UTF-8 and ASCII-8BIT
C:/jimi/Ruby21-x64/lib/ruby/2.1.0/resolv.rb:771:in `[]='
C:/jimi/Ruby21-x64/lib/ruby/2.1.0/resolv.rb:771:in `sender'
C:/jimi/Ruby21-x64/lib/ruby/2.1.0/resolv.rb:525:in `block in fetch_resource'
C:/jimi/Ruby21-x64/lib/ruby/2.1.0/resolv.rb:1096:in `block (3 levels) in resolv'
C:/jimi/Ruby21-x64/lib/ruby/2.1.0/resolv.rb:1094:in `each'
C:/jimi/Ruby21-x64/lib/ruby/2.1.0/resolv.rb:1094:in `block (2 levels) in resolv'
C:/jimi/Ruby21-x64/lib/ruby/2.1.0/resolv.rb:1093:in `each'
C:/jimi/Ruby21-x64/lib/ruby/2.1.0/resolv.rb:1093:in `block in resolv'
C:/jimi/Ruby21-x64/lib/ruby/2.1.0/resolv.rb:1091:in `each'
C:/jimi/Ruby21-x64/lib/ruby/2.1.0/resolv.rb:1091:in `resolv'
C:/jimi/Ruby21-x64/lib/ruby/2.1.0/resolv.rb:520:in `fetch_resource'
C:/jimi/Ruby21-x64/lib/ruby/2.1.0/resolv.rb:510:in `each_resource'
C:/jimi/Ruby21-x64/lib/ruby/2.1.0/resolv.rb:491:in `getresource'
C:/jimi/Ruby21-x64/lib/ruby/site_ruby/2.1.0/rubygems/remote_fetcher.rb:92:in `api_endpoint'
C:/jimi/Ruby21-x64/lib/ruby/site_ruby/2.1.0/rubygems/source.rb:46:in `api_uri'
C:/jimi/Ruby21-x64/lib/ruby/site_ruby/2.1.0/rubygems/source.rb:138:in `fetch_spec'
C:/jimi/Ruby21-x64/lib/ruby/site_ruby/2.1.0/rubygems/resolver/api_specification.rb:76:in `spec'
C:/jimi/Ruby21-x64/lib/ruby/site_ruby/2.1.0/rubygems/resolver/installer_set.rb:77:in `add_always_install'
C:/jimi/Ruby21-x64/lib/ruby/site_ruby/2.1.0/rubygems/dependency_installer.rb:463:in `resolve_dependencies'
C:/jimi/Ruby21-x64/lib/ruby/site_ruby/2.1.0/rubygems/commands/install_command.rb:238:in `install_gem'
C:/jimi/Ruby21-x64/lib/ruby/site_ruby/2.1.0/rubygems/commands/install_command.rb:299:in `block in install_gems'
C:/jimi/Ruby21-x64/lib/ruby/site_ruby/2.1.0/rubygems/commands/install_command.rb:295:in `each'
C:/jimi/Ruby21-x64/lib/ruby/site_ruby/2.1.0/rubygems/commands/install_command.rb:295:in `install_gems'
C:/jimi/Ruby21-x64/lib/ruby/site_ruby/2.1.0/rubygems/commands/install_command.rb:202:in `execute'
C:/jimi/Ruby21-x64/lib/ruby/site_ruby/2.1.0/rubygems/command.rb:307:in `invoke_with_build_args'
C:/jimi/Ruby21-x64/lib/ruby/site_ruby/2.1.0/rubygems/command_manager.rb:168:in `process_args'
C:/jimi/Ruby21-x64/lib/ruby/site_ruby/2.1.0/rubygems/command_manager.rb:138:in `run'
C:/jimi/Ruby21-x64/lib/ruby/site_ruby/2.1.0/rubygems/gem_runner.rb:54:in `run'
C:/jimi/Ruby21-x64/bin/gem:21:in `<main>'
有没有人遇到类似的问题并找到解决方案?不幸的是谷歌这次没用。
答案 0 :(得分:0)
我在Windows 7上遇到同样的错误,我通过执行以下更改修复了问题:
在文件 \ lib \ ruby \ {version} \ resolv.rb 上,我更改了以下一行:
request[0,2] = [id].pack('n')
要
request[0,2] = [id].pack('U')
仅供参考:在版本2.4.0上,行号为772。