Ruby-on-rails Gem 更新:在从 ASCII-8BIT 到 UTF-8 到 US-ASCII 的转换中无法将“\xE7”转换为 UTF-8

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4975973/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 00:24:05  来源:igfitidea点击:

Gem update: unable to convert "\xE7" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII

ruby-on-railsrubygems

提问by Meltemi

just ran gem updateon a light use server machine that hadn't been updated in a while... and am getting loads of 'unable to convert "\x??" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII for..." errors. Included is an except from console. anyone know what's going on?

刚刚gem update在一段时间没有更新的轻型服务器机器上运行......并且我得到了大量'无法转换“\ x??” 到 UTF-8 在从 ASCII-8BIT 到 UTF-8 到 US-ASCII 的转换中...”错误。包括一个来自控制台的异常。有人知道发生了什么吗?

$ sudo gem update
Installing ri documentation for railties-3.0.4...
Installing ri documentation for minitest-2.0.2...
Installing ri documentation for net-ssh-2.1.0...
unable to convert "\xE7" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII for lib/net/ssh/authentication/pageant.rb, skipping
unable to convert "\xC3" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII for lib/net/ssh/buffered_io.rb, skipping
unable to convert "\xC3" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII for lib/net/ssh/service/forward.rb, skipping
unable to convert "\xC3" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII for THANKS.rdoc, skipping
unable to convert "\xC3" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII for CHANGELOG.rdoc, skipping
Installing ri documentation for rails-3.0.4...
file 'lib' not found
Installing ri documentation for rails3-generators-0.17.4...
unable to convert "\xC3" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII for README.rdoc, skipping
Installing ri documentation for rdoc-3.5.3...
unable to convert U+201D from UTF-8 to US-ASCII for lib/rdoc/text.rb, skipping
unable to convert "\xC3" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII for History.txt, skipping
Installing ri documentation for rspec-core-2.5.1...
unable to convert "\xC2" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII for lib/rspec/core/subject.rb, skipping
Installing ri documentation for rspec-expectations-2.5.0...
unable to convert "\xC2" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII for lib/rspec/matchers.rb, skipping
Installing ri documentation for rspec-mocks-2.5.0...
Installing ri documentation for rspec-2.5.0...
Installing ri documentation for rspec-rails-2.5.0...

回答by Daniel Da Cunha

I have had a similar issue on my Mac OS X using iTerm2 instead of the default OS X Terminal.app. The LC_CTYPE is not set properly by iTerm2, once I have added export LC_CTYPE="utf-8"to ~/.bash_profile the gem installation goes smoothly.

我在使用 iTerm2 而不是默认的 OS X Terminal.app 的 Mac OS X 上遇到了类似的问题。iTerm2 没有正确设置 LC_CTYPE,一旦我添加export LC_CTYPE="utf-8"到 ~/.bash_profile 中,gem 安装就会顺利进行。

note: of course you can add the export to any of the other profilefiles

注意:当然您可以将导出添加到任何其他profile文件

回答by Jim Pfleger

The combination of Daniel and werm's answers worked for me, once I also unset LC_ALL. I ended up with this:

一旦我还取消了 LC_ALL 的设置,Daniel 和 werm 的答案的组合对我有用。我结束了这个:

export LC_CTYPE=en_US.UTF-8
export LANG=en_US.UTF-8
unset LC_ALL

回答by Justin Fortier

I was getting this same issue w/ installing another gem and didn't know how to get around it even after adding export LC_CTYPE="utf-8"to my ~/.bash_profile. It wasn't until I ran sudo gem updateafter that was able to install the gem.

我在安装另一个 gem 时遇到了同样的问题,即使添加export LC_CTYPE="utf-8"到我的~/.bash_profile. 直到我跑了sudo gem update之后才能够安装 gem。

Note that I wanted to contribute this to the original accepted answer, however not enough points yet. :( Nonetheless I hope this helps someone else.

请注意,我想将此贡献给最初接受的答案,但还不够。:( 尽管如此,我希望这对其他人有所帮助。

回答by werm

Try running localein your SSH terminal. This problem just started popping up for me. When I do localeI get this:

尝试locale在您的 SSH 终端中运行。这个问题刚刚开始出现在我身上。当我这样做时locale

LANG=C
LC_CTYPE="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_COLLATE="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_PAPER="C"
LC_NAME="C"
LC_ADDRESS="C"
LC_TELEPHONE="C" 
LC_MEASUREMENT="C"
LC_IDENTIFICATION="C"
LC_ALL=

The only fix I know of is to type LANG=en_US.UTF-8every time I login through SSH.

我所知道的唯一解决方法是LANG=en_US.UTF-8每次通过 SSH 登录时都键入。