0

I'm running into a UTF-8 issue with my rails application, which I recently took over from a different developer. While I known what the error means, and I know I need to force everything to UTF-8, but no luck. I've tried scrubbing through the application directory and updating all .rb files to UTF-8 (worked on a different app before).

I've also read through the different posts (here and here for example) on UTF-8 issues with ruby to no luck.

When I run bundle update or any other bundle action, I get the following: ~/my_app/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler.rb:285:in 'split': invalid byte sequence in UTF-8

with additional errors below for the bundler.

When I try to run rails s I get:

    /.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler.rb:285:in 'split': invalid byte sequence in UTF-8 (ArgumentError)

    from ~/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/setup.rb:7:in `<top (required)>'
    from ~/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:116:in `require'
    from ~/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:116:in `rescue in require'
    from ~/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:122:in `require'
    from ~/Development/gorefi/gorefi/config/boot.rb:6:in `<top (required)>'
    from ~/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:51:in `require'
    from /Users/gorefi/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:51:in `require'

UPDATE

I tried to create a new app and ran into this error, which is definitely related. Not sure at all what's going on now!

ArgumentError: invalid byte sequence in UTF-8
An error occurred while installing rake (10.1.0), and Bundler cannot continue.
Make sure that `gem install rake -v '10.1.0'` succeeds before bundling.
2
  • Is it possible that some of your files are not actually UTF-8 files? See this answer: stackoverflow.com/questions/6374756/… Commented Oct 15, 2013 at 21:39
  • Maybe? How would I be able to check which file/gem specifically is giving the issue to bundler? Commented Oct 15, 2013 at 22:01

1 Answer 1

3

Line 285 in bundler.rb is:

path = ENV['PATH'].split(File::PATH_SEPARATOR).find do |p|

So it is likely that you have something in your path that bundler is not expecting. I suggest you echo the path, see if it is something you can do without for a short while, and if so, set the environment variable to not contain whatever is causing the problem.

Longer term answer will depend on what the path data is. However, the chances are if this is a new install you are debugging, that this is just one more hurdle, and something else will crop up. You will want to create a list of things to fix properly once you have a handle on running the app in the first place.

Sign up to request clarification or add additional context in comments.

3 Comments

Can you elaborate on this? bundler isn't expecting the encoding type of the file I presume. Should i just set the env variable in my .bash_profile? I'm on a Mac.
@Elijah Murray: Check what the data is first, not worth fixing if I'm wrong. I couldn't find a way to tell Ruby to expect different encodings in environment variables, and I could not see a way for you to intercept reading ENV and force the encoding to whatever it is supposed to be on a Mac path. I've removed the advice about Windows (I must of mis-remembered your question)
I just had this problem. It turns out that I'd edited my .bash_profile to get Sublime Text 3 working from the command line, according to the instructions here: stackoverflow.com/questions/16199581/… There's a non-UTF-8 character at the end of this line: export PATH=/bin:/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:$PATH↲ I copied it in, not noticing it, and it got to ENV["PATH"]. Removing it fixes this problem. I've submitted an edit request at that other topic, so hopefully that'll go through and not cause trouble for others.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.