38

just ran gem update on 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?

$ 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...
Meltemi
  • 37,979
  • 50
  • 195
  • 293

4 Answers4

56

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.

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

David Underwood
  • 4,908
  • 1
  • 19
  • 25
Daniel Da Cunha
  • 1,004
  • 11
  • 15
  • This resolved the problem for me. Occurred when connecting to my Mac remotely using Panic’s Prompt SSH client. – Daniel Apr 16 '12 at 21:30
  • ```export LC_CTYPE="utf-8"``` failed on Fedora 19 with error: ```-bash: warning: setlocale: LC_CTYPE: cannot change locale (utf-8): No such file or directory``` Any idea why? Thanks – mkelley33 Oct 27 '13 at 03:27
  • 2
    Also, I should add that ```export LC_CTYPE=en_US.UTF-8``` worked :) – mkelley33 Oct 27 '13 at 03:28
  • Be sure to run `sudo gem update` after adding this do your `~/.bash_profile` script if you're doing a `gem install`. The issue persisted when installing until I ran that first. – Justin Fortier Jun 18 '15 at 20:47
  • I have the issue, even though I already _am_ running the default OS X Terminall.app. – Nicolas Miari Nov 30 '15 at 02:43
  • @NicolasMiari have you tried to run `locale` in your terminal ? – Daniel Da Cunha Dec 01 '15 at 06:06
  • I did now. The output is `LANG= LC_COLLATE="C" LC_CTYPE="UTF-8" LC_MESSAGES="C" LC_MONETARY="C" LC_NUMERIC="C" LC_TIME="C" LC_ALL= ` – Nicolas Miari Dec 01 '15 at 06:13
18

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

export LC_CTYPE=en_US.UTF-8
export LANG=en_US.UTF-8
unset LC_ALL
Jim Pfleger
  • 301
  • 3
  • 7
  • thanks this was the correct answer for me on iTerm2 and a standard 10.04 ubuntu install with some locale problems! – Richard Frank Dec 20 '12 at 15:59
  • On Fedora 19 using gnome-terminal this mostly worked except for one error: ```unable to convert "\xD0" from ASCII-8BIT to UTF-8 for lib/redcarpet.so, skipping``` I'm not sure why this happened, but any further advice would be most awesomely welcomed! – mkelley33 Oct 27 '13 at 03:25
  • This fixed my unable to convert "\xCA" from ASCII-8BIT to UTF-8 for redcarpet – Bae Dec 18 '14 at 12:20
5

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 update after that was able to install the 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.

Justin Fortier
  • 451
  • 5
  • 6
5

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

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-8 every time I login through SSH.

rjmunro
  • 27,203
  • 20
  • 110
  • 132
werm
  • 458
  • 1
  • 6
  • 17
  • 2
    Encountered this on a Solaris 10 machine that I'm trying to install ruby and rubygems on. In my ~/.bashrc file, I put `LC_CTYPE=en_US.UTF-8 LANG=en_US.UTF-8 export LC_CTYPE LANG`. That made the problems disappear for me. – mj1531 Dec 12 '11 at 17:45