Rails: Invalid byte sequence in US-ASCII (Argument Error) when I run rake db:seed Rails: Invalid byte sequence in US-ASCII (Argument Error) when I run rake db:seed ruby-on-rails ruby-on-rails

Rails: Invalid byte sequence in US-ASCII (Argument Error) when I run rake db:seed


You're receiving an encoding error because your filesystem isn't configured to encode the date you've added (since presumably it includes new characters – possibly in your HTML entity encoded map URL – that didn't exist in your prior data seed).

The following will should resolve this error by setting the UTF-8 locale on your machine:

# from your command lineexport LANG=en_US.UTF-8export LANGUAGE=en_US.UTF-8export LC_ALL=en_US.UTF-8bundle

The benefit of setting a system locale is that all gems (going forward) will be bundled using UTF-8 encoding.

EDIT:

Alternatively, if you don't want to change your system encoding, you can set your encoding project-wide by specifying an encoding standard in your Gemfile:

if RUBY_VERSION =~ /1.9/ # assuming you're running Ruby ~1.9  Encoding.default_external = Encoding::UTF_8  Encoding.default_internal = Encoding::UTF_8end


Add

#encoding: utf-8

at the top of the file


You can also try export RUBYOPT="-KU -E utf-8:utf-8"as mentioned in this GH thread