How to prevent error "code converter not found (UTF-8)"?
Asked Answered
A

2

7

I'm getting this error in my production environment (CentOS 5.6), but it runs fine in development (Ubuntu 11.04). In both environments, the app is using Ruby 1.9.3 and Rails 3.0.9 and is served with passenger and nginx. My mechanize gem version is 2.3.

code converter not found (UTF-8)

The last line of this code triggers it:

mech = Mechanize.new
page = mech.get("http://myurl.com/login.php?login_name=a&password=b")
form = page.form_with(:name => "loginForm")
form.field_with(:name => "active_pgm").value = '1'
page = form.submit

Any ideas? I do have config.encoding = "utf-8" in my application.rb.

Avernus answered 27/3, 2012 at 17:56 Comment(2)
Do you have a stacktrace around? And ENV on both machines.Strongarm
Sure. It's too big to paste so here's a link: pastebin.com/S41Z4zK6Avernus
N
1

Try changing your application.rb to read config.encoding = "UTF-8". I'm not sure why that would be an issue but it is worth a shot since the error complains about not finding 'UTF-8'(uppercase).

Noun answered 27/3, 2012 at 19:25 Comment(0)
W
1

This is a longshot yet perhaps it will help you, because I saw similar errors on RHEL for other parsing gems.

The solution I found was not in Rails -- it was adding these lines to the system environment:

LANGUAGE=en_US.UTF-8
LC_CTYPE=en_US.UTF-8
LC_ALL=en_US.UTF-8
Wellestablished answered 3/4, 2012 at 12:55 Comment(1)
Thanks but it didn't help. To keep my app working, I moved the production instance to an ubuntu machine and of course the issue doesn't happen there. I may try setting up a new centos machine and see if I get the same thing.Avernus

© 2022 - 2024 — McMap. All rights reserved.