Ruby on Rails on Passenger and Redmine: incompatible character encodings: UTF-8 and ASCII-8BIT

After migrating Redmine to a new server, I've encountered such an error:

ActionView::Template::Error (incompatible character encodings: UTF-8 and ASCII-8BIT):
    3: <div class="box tabular settings">
    4: <p><%= setting_select :ui_theme, Redmine::Themes.themes.collect {|t| [t.name, t.id]}, :blank => :label_default, :label => :label_theme %></p>
    5: 
    6: <p><%= setting_select :default_language, lang_options_for_select(false) %></p>
    7: 
    8: <p><%= setting_select :start_of_week, [[day_name(1),'1'], [day_name(6),'6'], [day_name(7),'7']], :blank => :label_language_based %></p>
    9: <% locale = User.current.language.blank? ? ::I18n.locale : User.current.language %>
  app/helpers/settings_helper.rb:40:in `setting_select'
  app/views/settings/_display.html.erb:6:in `block in _app_views_settings__display_html_erb__83012438_101817890'
  app/views/settings/_display.html.erb:1:in `_app_views_settings__display_html_erb__83012438_101817890'
  app/views/common/_tabs.html.erb:24:in `block in _app_views_common__tabs_html_erb__985403460_101198110'
  app/views/common/_tabs.html.erb:23:in `each'
  app/views/common/_tabs.html.erb:23:in `_app_views_common__tabs_html_erb__985403460_101198110'
  app/helpers/application_helper.rb:263:in `render_tabs'
  app/views/settings/edit.html.erb:3:in `_app_views_settings_edit_html_erb__815292708_88944890'
  app/controllers/settings_controller.rb:26:in `index'

My database and all my configs were set to UTF8, so it looked like the problem was somewhere in Apache. Partialy I was right. To fix this issue, you need to add following lines:

export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8

to /etc/apache2/envvars and then just restart server:

# /etc/apache2/envvars
/etc/init.d/apache2 restart

Categories: Hosting, Linux, Rails, Ruby, Software

1 Comment

  1. Thanks for this. Was the fix for a problem that was proving difficult to track down.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Copyright © 2024 Closer to Code

Theme by Anders NorenUp ↑