Can't install gems with Ruby: “invalid byte sequence in UTF-8”

2

I'm using Mountain Lion. I've installed Ruby first with RVM, then with rbenv. I can assure it's running the latest one with which ruby, it correctly points to the one installed with rbenv.

gem won't install any gem, it always throws me the same error (not always in the same file, but the same error with split:

Users/Macbook/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:1357:in `split': invalid byte sequence in UTF-8 (ArgumentError)
    from /Users/Macbook/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:1357:in `find_executable0'
    from /Users/Macbook/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:1564:in `pkg_config'
    from extconf.rb:15:in `<main>'

I've tried setting these exports in my .profile, without luck:

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

I've also updated bash with brew, and activated it with chsh. iTerm2 is correctly configurated with UTF-8 encoding too.

I have no idea what else to do now. I have XCode 4.6.3.

Cristian

Posted 2013-10-14T16:03:01.193

Reputation: 81

Did you try using rbenv instead of rvm? I 've also had some issues using rvm but none so far using rbenv

– jmoreira – 2013-10-15T12:48:00.350

Yes, same results. – Cristian – 2013-10-16T13:30:59.227

Answers

0

The problem was solved cleaning up all files related with the setting up of the PATHenvironment variable (.bash_profile, .profile, .bashrc) and then installing rvmagain. Executing an echo $PATHrevealed a strange character which broke bundler's processing of the PATH.

Cristian

Posted 2013-10-14T16:03:01.193

Reputation: 81

0

I have 64 bit Cygwin, Ruby 2.0.0 and gem 2.4.1 and was experiencing the same issue. gem install ..., gem update, everything ended with "ERROR: While executing gem ... (ArgumentError) invalid byte sequence in UTF-8".

I had also all locales set to "en_US.UTF-8".

I have read somewhere that it should help to set LANG to an empty string or "C.BINARY", but it didn't help. But it was good hint to start experimenting.

Finally I have solved that by setting both LANG and LC_ALL to an empty string. All other locale environment variables (LC_CTYPE etc.) was automatically set to "C.UTF-8" by that, LANG and LC_ALL remained empty.

Now gem is finally working.

I guess, that you had the same reason. When you have "cleaned" your dotfiles, your probably changed values of your locales.

Dawid Ferenczy Rogožan

Posted 2013-10-14T16:03:01.193

Reputation: 346