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' [firstname.lastname@example.org] executing command ** [out :: email@example.com] ArgumentError: invalid byte sequence in US-ASCII ** [out :: firstname.lastname@example.org] An error occurred while installing useragent (0.2.3), ** [out :: email@example.com] and Bundler cannot continue. ** [out :: firstname.lastname@example.org] 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