1

SOLVED: Used rvm to install ruby 2.0.0 and rails 3. After using a newer version of ruby, this problem disappeared.

When I run $ rails server locally and try to load any of the static assets in the browser, eg "localhost:3000/assets/javascripts/main.js", I get the following error:

Internal Server Error

invalid encoding ("UTF-8//IGNORE", "BINARY")
WEBrick/1.3.1 (Ruby/1.8.7/2012-02-08) at localhost:3000

This happens on all static assets. What could be the problem here?

I'm using Mac OS X 10.7.5

Stack trace:

[2013-02-28 12:59:12] ERROR Iconv::InvalidEncoding: invalid encoding ("UTF-8//IGNORE", "BINARY")
/Library/Ruby/Gems/1.8/gems/i18n-0.6.3/lib/i18n/core_ext/string/encoding.rb:7:in `conv'
/Library/Ruby/Gems/1.8/gems/i18n-0.6.3/lib/i18n/core_ext/string/encoding.rb:7:in `force_encoding'
/Library/Ruby/Gems/1.8/gems/actionpack-3.2.12/lib/action_dispatch/middleware/static.rb:41:in `escape_glob_chars'
/Library/Ruby/Gems/1.8/gems/actionpack-3.2.12/lib/action_dispatch/middleware/static.rb:14:in `match?'
/Library/Ruby/Gems/1.8/gems/actionpack-3.2.12/lib/action_dispatch/middleware/static.rb:56:in `call'
/Library/Ruby/Gems/1.8/gems/railties-3.2.12/lib/rails/engine.rb:479:in `call'
/Library/Ruby/Gems/1.8/gems/railties-3.2.12/lib/rails/application.rb:223:in `call'
/Library/Ruby/Gems/1.8/gems/rack-1.4.5/lib/rack/content_length.rb:14:in `call'
/Library/Ruby/Gems/1.8/gems/railties-3.2.12/lib/rails/rack/log_tailer.rb:17:in `call'
/Library/Ruby/Gems/1.8/gems/rack-1.4.5/lib/rack/handler/webrick.rb:59:in `service'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
/Library/Ruby/Gems/1.8/gems/rack-1.4.5/lib/rack/handler/webrick.rb:13:in `run'
/Library/Ruby/Gems/1.8/gems/rack-1.4.5/lib/rack/server.rb:268:in `start'
/Library/Ruby/Gems/1.8/gems/railties-3.2.12/lib/rails/commands/server.rb:70:in `start'
/Library/Ruby/Gems/1.8/gems/railties-3.2.12/lib/rails/commands.rb:55
/Library/Ruby/Gems/1.8/gems/railties-3.2.12/lib/rails/commands.rb:50:in `tap'
/Library/Ruby/Gems/1.8/gems/railties-3.2.12/lib/rails/commands.rb:50
script/rails:6:in `require'
script/rails:6
bfw
  • 157
  • 11
  • Which version of Rails and Ruby are you using? `gem list rails` or `bundle list rails` to get the Rails version. I'm assuming if you do `ruby -v` it will say 1.8.7 as above, which means you are using the system Ruby, which is quite out of date now. I suggest you upgrade before moving forwards. Take a look at [RVM](https://rvm.io/) or [chruby](https://github.com/postmodern/chruby) or [rbenv](https://github.com/sstephenson/rbenv/), (maybe by using [Homebrew](http://mxcl.github.com/homebrew/)) and then add the 1.9.x or 2.x version of Ruby and start there. – ian Feb 28 '13 at 11:44
  • I've upgraded ruby to version 1.9.3 using brew. I'm using rails version 3.2.12. The problem persists. – bfw Feb 28 '13 at 11:48
  • still with _exactly_ the same error? – ian Feb 28 '13 at 11:55
  • Yes. Although from the stack trace I added above, it looks like rails is still using Ruby 1.8.*, since it's using gems in /Library/Ruby/Gems/1.8/.... – bfw Feb 28 '13 at 11:59
  • Try `ruby -v` again, I'm pretty sure it will say you're using 1.8.7. I'd really advise using RVM or something similar to be able to switch rubies easily. See http://stackoverflow.com/questions/8730676/how-can-i-switch-to-ruby-1-9-3-installed-using-homebrew – ian Feb 28 '13 at 12:04
  • $ruby -v says: ruby 1.9.3p374 (2013-01-15 revision 38858) [x86_64-darwin11.4.2] But rails is still using the old one, From $rails server: [2013-02-28 13:05:10] INFO ruby 1.8.7 (2012-02-08) [universal-darwin11.0] – bfw Feb 28 '13 at 12:10
  • Remove the old gems, and I'd install the new ones with [Bundler](http://gembundler.com/v1.1/bundle_install.html), using the `--binstubs` switch so that you then use `bin/rails s` instead of `rails s` – ian Feb 28 '13 at 13:04

0 Answers0