Reputation: 875
Can't seem to figure this one out, trying to run any script I get this error:
invalid byte sequence in UTF-8 (ArgumentError)
I have a new OS X machine everything fresh, using Ruby 1.9.3 and Rails 3.2.1 , I've been developing for days with no problem.
I left for a few hours today and now I can't run any scripts.
I first got the error trying a new migration and thought it was an issue with Postgres, reinstalled, made sure all tables were encoded with UTF-8.
I've also reinstalled RVM and Rails.
I thought it would be easier to debug if it had to do with the database, but I've created new applications and can't even start the server, receiving the same error.
Full stack trying to run the server in a new application on sqlite3
/Users/mgaughan/.rvm/gems/ruby-1.9.3-p0@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:136:in `split': invalid byte sequence in UTF-8 (ArgumentError)
from /Users/mgaughan/.rvm/gems/ruby-1.9.3-p0@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:136:in `setup_environment'
from /Users/mgaughan/.rvm/gems/ruby-1.9.3-p0@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:13:in `setup'
from /Users/mgaughan/.rvm/gems/ruby-1.9.3-p0@global/gems/bundler-1.0.21/lib/bundler.rb:110:in `setup'
from /Users/mgaughan/.rvm/gems/ruby-1.9.3-p0@global/gems/bundler-1.0.21/lib/bundler/setup.rb:7:in `'
from /Users/mgaughan/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `require'
from /Users/mgaughan/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `rescue in require'
from /Users/mgaughan/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
from /Users/mgaughan/Code/something/config/boot.rb:6:in `'
from /Users/mgaughan/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/mgaughan/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from script/rails:5:in `'
Now the more I look at it there is obviously something screwed up with postgresql because in applications on postgresql, bundle fails install pg
Stack trace:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/mgaughan/.rvm/rubies/ruby-1.9.3-p0/bin/ruby extconf.rb
checking for pg_config... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/mgaughan/.rvm/rubies/ruby-1.9.3-p0/bin/ruby
--with-pg
--without-pg
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
/Users/mgaughan/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/mkmf.rb:1357:in `split': invalid byte sequence in UTF-8 (ArgumentError)
from /Users/mgaughan/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/mkmf.rb:1357:in `find_executable0'
from /Users/mgaughan/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/mkmf.rb:1384:in `block in find_executable'
from /Users/mgaughan/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
from /Users/mgaughan/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
from /Users/mgaughan/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/mgaughan/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
from /Users/mgaughan/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/mgaughan/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
from /Users/mgaughan/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
from /Users/mgaughan/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/mkmf.rb:1383:in `find_executable'
from extconf.rb:27:in `'
Gem files will remain installed in /Users/mgaughan/.rvm/gems/ruby-1.9.3-p0/gems/pg-0.12.2 for inspection.
Results logged to /Users/mgaughan/.rvm/gems/ruby-1.9.3-p0/gems/pg-0.12.2/ext/gem_make.out
An error occured while installing pg (0.12.2), and Bundler cannot continue.
Make sure that `gem install pg -v '0.12.2'` succeeds before bundling.
The mkmf.log file it mentions to check is blank.
So I'm guessing that Postgresql might be the root of this problem, but I'm pretty stumped as to why a new application using sqlite3 would still throw this byte error.
Any help would be appreciated, let me know if there's any more info I can provide.
The problem seemed to have resolved itself.
The only change to my machine I made was as @Frederick Cheung suggested; I removed an sbin folder from my Path that was from an old NGINX install that had been uninstalled.
Possibly that was the difference, but it seems unlikely to me.
Regardless, I ran a command and everything was working fine and has been for days.
Upvotes: 1
Views: 354
Reputation: 84182
Judging by the stacktrace, the PATH
environment variable contains some unsavoury data. I'd start by checking it and removing anything that doesn't look like it belongs there
Upvotes: 1
Reputation: 20069
Do any of your initializers or environment configs (application.rb, development.rb etc) contain invalid characters?
Often this will occur if you've grabbed a javascript file off the net which has funky characters in the header. If you include it in application.js the Sprockets parser throws a wobbly about it.
In this instance it looks like it is when you're trying to run up your app, so it suggests to me it is an invalid character in one of the files that is used during initialization.
Upvotes: 0