I have automated my rails deployment with Capistrano. It was working fine. I have added a new gem useragent to my Gemfile as below
gem 'useragent', '0.2.3', :git => "http://github.com/jilion/useragent"
I committed the code and when try to deploy the code again got below error
2013-09-17 16:50:35 executing `bundle:install' [email@example.com] executing command ** [out :: firstname.lastname@example.org] ArgumentError: invalid byte sequence in US-ASCII ** [out :: email@example.com] An error occurred while installing useragent (0.2.3), ** [out :: firstname.lastname@example.org] and Bundler cannot continue. ** [out :: email@example.com] Make sure that `gem install useragent -v '0.2.3'` succeeds before bundling.
The issue is discussed in length here at bundler issue tracking .
The reason is that by default ruby set to evaluate any file as US-ASCII encoding. But useragent gem is having some non ASCII characters in it, so throwing the error. It can be solved by setting the default language to utf-8 which support much wider range of encoding. The solution is to add below line to Gemfile at the top.
if RUBY_VERSION =~ /1.9/ # assuming you're running Ruby ~1.9 Encoding.default_external = Encoding::UTF_8 Encoding.default_internal = Encoding::UTF_8 end