tags:

views:

161

answers:

3

Here's the stack: Sproutcore 1.0.1046. Ruby 1.9.1, in RVM. Thin 1.2.7. Thor 0.13.8. Rack 1.2.1. Eventmachine 0.12.10. Erubis 2.6.6.

When I start the sc-server on any application, my first request to this server produces this in the console log:

ArgumentError: invalid byte sequence in US-ASCII

...followed by this stack trace. (I've listed gems which appear in the stack trace above, but there's a complete gemset list in the same gist as the stack trace.)

Research on the error message points out that this is a common problem with Ruby 1.9, but the stack trace suggests that the problem is in one of the gems somewhere.

I have:

  • Upgraded my OS (Mac OS X 10.5 to 10.6) in order to get the latest gcc Apple provides.
  • Reinstalled RVM.
  • Reinstalled Ruby.
  • Reinstalled all the relevant gems.

And yet I still have this problem on one system, but not on another. (N.B. there are several devs working on this code, and I'm the only one seeing this problem. I'm 99% certain it's not our code.) I guess what I'm saying is that I've cleared and rebuilt a lot of gems to try to isolate or remove this glitch, and yet I still haven't gotten rid of it.

Where should I look next?

+1  A: 

You have some special setting in your bash environment that is setting ruby to use US-ASCII , this happened to me trying to execute sc-server from a remote terminal... I'm not really sure what it is, but it doesn't use UTF-8 and that's when it runs into trouble.

Juan Pinzon
You can see what's in your environment variables by running the 'env' command from bash. Or by examining the ENV hash in Ruby.
AboutRuby
THANK YOU. I checked the environments on the two systems, and the one that worked had several `en_US.UTF-8` settings, and the one that didn't has several `en_US.us-ascii` settings. The LC_CTYPE environment variable seems to be the key, because setting that in my .bash_profile seemed to solve the problem without changing any others.
pjmorse
A: 

You can probably also change Encoding.default_external

rogerdpack
A: 

Thanks so much for the Encoding.default_external suggestion. I was having the same problem, despite correctly set magic comments and environment variables. In Rails 2.3.9 I added this before_filter in application_controller.rb, resolved the issue:

def set_encoding
  Encoding.default_external = 'UTF-8'
end
John