Skip to content

ArgumentError: invalid byte sequence in US ASCII

technicalpickles edited this page Oct 11, 2012 · 1 revision

After Upgrading Ruby with Moonshine to 1.9.3, you may notice errors during deployment for bundle install like:

** [out :: example.com] notice: /Exec[bundle install]/returns: ArgumentError: invalid byte sequence in US-ASCII
** [out :: example.com] notice: /Exec[bundle install]/returns: An error occured while installing thor (0.15.4), and Bundler cannot continue.
** [out :: example.com] notice: /Exec[bundle install]/returns: Make sure that `gem install thor -v '0.15.4'` succeeds before bundling.

This has to do with Ruby 1.9.3 and it's encoding goodness. When combined with Puppet, under the hood, setting the default encoding to ANSI C, this leads to problems with gems that have UTF8 in their gem specifications.

There's a few workarounds for it, but they don't all work with the combination of capistrano/puppet/moonshine. Instead, add this to the top of your Gemfile:

if RUBY_VERSION =~ /1.9/
    Encoding.default_external = Encoding::UTF_8
    Encoding.default_internal = Encoding::UTF_8
end
Clone this wiki locally