When run bundle get invalid byte sequence in US-ASCII
Asked Answered
C

3

24

I'm trying to deploy my Rails 3.0 app. I use rvm and ruby 1.9.2 (p 180 or p 290 - no difference) on the FreeBSD production server. When I run bundle command, I get this exception on every :git gem (it seems that exception is raised only when I use edge versions with :git option in Gemfile):

...
Installing has_scope (0.5.1) 
Installing responders (0.6.4) 
Using inherited_resources (1.2.2) from https://github.com/josevalim/inherited_resources.git (at master) /home/tmr/data/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:1915:in `gsub': invalid byte sequence in US-ASCII (ArgumentError)
from /home/tmr/data/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:1915:in `to_yaml'
from /home/tmr/data/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/builder.rb:79:in `block (2 levels) in write_package'
from /home/tmr/data/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/package/tar_output.rb:73:in `block (3 levels) in add_gem_contents'
from /home/tmr/data/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/package/tar_writer.rb:83:in `new'
from /home/tmr/data/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/package/tar_output.rb:67:in `block (2 levels) in add_gem_contents'
from /home/tmr/data/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/package/tar_output.rb:65:in `wrap'
from /home/tmr/data/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/package/tar_output.rb:65:in `block in add_gem_contents'
from /home/tmr/data/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/package/tar_writer.rb:113:in `add_file'
from /home/tmr/data/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/package/tar_output.rb:63:in `add_gem_contents'
from /home/tmr/data/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/package/tar_output.rb:31:in `open'
from /home/tmr/data/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/package.rb:44:in `open'
from /home/tmr/data/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/builder.rb:78:in `block in write_package'
from /home/tmr/data/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/open-uri.rb:35:in `open'
from /home/tmr/data/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/open-uri.rb:35:in `open'
from /home/tmr/data/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/builder.rb:77:in `write_package'
from /home/tmr/data/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/builder.rb:39:in `build'
from /home/tmr/data/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.18/lib/bundler/source.rb:456:in `block in generate_bin'
from /home/tmr/data/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.18/lib/bundler/source.rb:456:in `chdir'
from /home/tmr/data/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.18/lib/bundler/source.rb:456:in `generate_bin'
from /home/tmr/data/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.18/lib/bundler/source.rb:565:in `install'
from /home/tmr/data/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.18/lib/bundler/installer.rb:58:in `block (2 levels) in run'
from /home/tmr/data/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.18/lib/bundler/rubygems_integration.rb:93:in `with_build_args'
from /home/tmr/data/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.18/lib/bundler/installer.rb:57:in `block in run'
from /home/tmr/data/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.18/lib/bundler/installer.rb:49:in `run'
from /home/tmr/data/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.18/lib/bundler/installer.rb:8:in `install'
from /home/tmr/data/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.18/lib/bundler/cli.rb:220:in `install'
from /home/tmr/data/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.18/lib/bundler/vendor/thor/task.rb:22:in `run'
from /home/tmr/data/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.18/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
from /home/tmr/data/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.18/lib/bundler/vendor/thor.rb:263:in `dispatch'
from /home/tmr/data/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.18/lib/bundler/vendor/thor/base.rb:386:in `start'
from /home/tmr/data/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.18/bin/bundle:13:in `<top (required)>'
from /home/tmr/data/.rvm/gems/ruby-1.9.2-p180/bin/bundle:19:in `load'
from /home/tmr/data/.rvm/gems/ruby-1.9.2-p180/bin/bundle:19:in `<main>'

My gemfile:

source 'http://rubygems.org'

group :production do
  gem "unicorn"
end

gem 'rails', '3.0.10'
gem 'devise' #, :git=>'https://github.com/plataformatec/devise.git'
gem 'russian', :git => 'https://github.com/yaroslav/russian.git'
gem 'i18n'
gem 'cancan', :git=>'https://github.com/ryanb/cancan.git'
gem 'riddle', :git => 'git://github.com/freelancing-god/riddle.git'
gem 'thinking-sphinx', :git => 'https://github.com/freelancing-god/thinking-sphinx.git', :branch=>'rails3'
gem 'inherited_resources', :git=> 'https://github.com/josevalim/inherited_resources.git'
gem 'has_scope'
gem 'simple_form'
gem 'dynamic_form'
#gem "crummy", ">= 1.0.1"
gem "haml"
gem 'jquery-rails', '>= 0.2.6'
gem 'kaminari'
gem 'mysql2', '< 0.3'
gem "paperclip", "~> 2.3"
gem "whenever"

group :development do
  gem 'haml-rails' #, :git=>"https://github.com/indirect/haml-rails.git"
  gem "capistrano"
end

1.9 is horrible with it's encoding problems... could you help once again?

Cauterant answered 17/8, 2011 at 15:56 Comment(1)
Problem is somewhere in yaml, because if I don't use edge gem versions, I get another psych yaml exception. Any ideas? I have to deploy it today or die!)Cauterant
C
35
export LANG=en_US.UTF-8    
export LC_ALL=en_US.UTF-8
Cauterant answered 19/8, 2011 at 19:4 Comment(1)
If you don't speak Russian but you speak English, use en_US.UTF-8Onassis
C
52

For me works, adding this lines to the top of Gemfile

if RUBY_VERSION =~ /1.9/
  Encoding.default_external = Encoding::UTF_8
  Encoding.default_internal = Encoding::UTF_8
end
Conscious answered 19/1, 2012 at 13:32 Comment(7)
For some cases that advice works. But didn't work for mine. In my case it was important to set the encoding of bash, not ruby.Cauterant
Worked for me! YAAAAAAAAAAAAAAAAAAAAAAAHOOOOOOOOOOOOOOOOOOOOOOOOOOOReplica
Totally fixed a problem I've been struggling with for a long while! Cheers!Basil
Solve my problem and save my life.Chlo
If it wern't for you, this problem probably would have cost me my life too :p Thank you.Earle
@Ulitiy can you explain your solution further? Not sure how to do that.Squire
@Squire my solution is using bash variable LANG and LC_ALL. You should write that in .bashrc file.Cauterant
C
35
export LANG=en_US.UTF-8    
export LC_ALL=en_US.UTF-8
Cauterant answered 19/8, 2011 at 19:4 Comment(1)
If you don't speak Russian but you speak English, use en_US.UTF-8Onassis
P
1

In Debian/Ubuntu systems, run:

$ dpkg-reconfigure locales

And select your locales.

Priory answered 5/9, 2011 at 19:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.