RVM, Ruby 1.9.2, Rails 2.3.8, Passenger and "Invalid USE-ASCII Byte Sequence"

I just started the upgrade process from Ruby 1.8.7 to Ruby 1.9.2 (using RVM). I have all my applications running using script / server '(or' rails server ') with 1.9.2, however, only Rails 3.0.0 RC applications work with Passenger. The error message given by Rails 2.3.8 applications is as follows:

invalid byte sequence in US-ASCII

I assume this is the Passenger's problem. I installed Passenger 2.2.15 using the RVM manual found here . Any ideas how to fix this error? Thank you I updated to enable stack tracing:

/Users/kevin/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-2.3.8/lib/action_view/template_handlers/erb.rb:14:in `compile'
/Users/kevin/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-2.3.8/lib/action_view/template_handler.rb:11:in `call'
/Users/kevin/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-2.3.8/lib/action_view/renderable.rb:19:in `compiled_source'
/Users/kevin/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-2.3.8/lib/action_view/renderable.rb:68:in `compile!'
/Users/kevin/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-2.3.8/lib/action_view/renderable.rb:61:in `compile'
/Users/kevin/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-2.3.8/lib/action_view/renderable.rb:28:in `render'
/Users/kevin/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-2.3.8/lib/action_view/template.rb:205:in `render_template'
/Users/kevin/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-2.3.8/lib/action_view/base.rb:265:in `render'
/Users/kevin/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-2.3.8/lib/action_view/base.rb:352:in `_render_with_layout'
/Users/kevin/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-2.3.8/lib/action_view/base.rb:262:in `render'
/Users/kevin/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-2.3.8/lib/action_controller/base.rb:1250:in `render_for_file'
/Users/kevin/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-2.3.8/lib/action_controller/base.rb:942:in `render'
/Users/kevin/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-2.3.8/lib/action_controller/benchmarking.rb:51:in `block in render_with_benchmark'
/Users/kevin/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-2.3.8/lib/active_support/core_ext/benchmark.rb:17:in `block in ms'
/Users/kevin/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/benchmark.rb:309:in `realtime'
/Users/kevin/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-2.3.8/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/Users/kevin/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-2.3.8/lib/action_controller/benchmarking.rb:51:in `render_with_benchmark'
/Users/kevin/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-2.3.8/lib/action_controller/mime_responds.rb:135:in `block in custom'
/Users/kevin/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-2.3.8/lib/action_controller/mime_responds.rb:179:in `call'
/Users/kevin/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-2.3.8/lib/action_controller/mime_responds.rb:179:in `block in respond'
/Users/kevin/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-2.3.8/lib/action_controller/mime_responds.rb:173:in `each'
/Users/kevin/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-2.3.8/lib/action_controller/mime_responds.rb:173:in `respond'
/Users/kevin/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-2.3.8/lib/action_controller/mime_responds.rb:107:in `respond_to'
/Users/kevin/Sites/sample/app/controllers/main_controller.rb:7:in `index'
+5
5

# encoding: UTF-8
main_controller.rb. , ASCII, , .

Ruby 1.9 :

  • : US-ASCII, .
  • : , , . . : open (mydata.txt, "r: UTF-8" ).
  • : , . nil, , . - , IO.open. : open (mydata.txt, 'r: UTF-8: UTF-16LE')

II .

+6

Ubuntu (11.10), /etc/apache 2/envvars:

## The locale used by some modules like mod_dav
export LANG=C
## Uncomment the following line to use the system default locale instead:
#. /etc/default/locale

, /etc/default/locale ( LANG="en_US.UTF-8"), , ruby.

+5

, .

+3

pjmorse , Passenger/Rails, LANG.

Rails script/server LANG = en_CA.UTF-8, Passenger.

: , Ruby , . http://blog.phusion.nl/2008/12/16/passing-environment-variables-to-ruby-from-phusion-passenger/

:

#!/bin/sh
export LANG=en_CA.UTF-8
exec "/Your_Default_Ruby_Path/ruby" "$@"

. Your_Default_Ruby_Path - , PassengerRuby http.conf, .

+2
source

Welcome to the wonderful world of forced string encoding; the error is the difference in the behavior of Ruby 1.9.x versus Ruby 1.8.x in strings.

Check http://blog.phusion.nl/2009/02/02/getting-ready-for-ruby-191/ - may be useful. You probably just need to update your gemset.

+1
source

All Articles