Redmine and Ruby 1.9.2. Solution.

There are a lot of project management systems for programmers(to track bug reports, project tickets, timelines, to work with tasks and documents). Today main products for that goals are Redmine, Trac, Jira, Bugzilla. Redmine is much more interesting for me because it's written on Ruby, has wiki, task management, charts, advanced user groups and permissions for projects. And looks comfortable for work after Jira or Trac.

But as other opensource project it has own installation problems. So, Redmine uses  old version of Ruby Rails 2.3.14, need old versions of rack and rake and that's why main problem of project is compability with Ruby 1.9.2.

I've installed Redmine with Ruby 1.9.2 on Ubuntu 11.10.(with recomended in manual versions of mysql, rack, rake, rails, etc.).

In my case I've decided that if Redmine need special versions of gems than I will install all gems in separate folder(e.g. /web/redmine/gems) using environment variable RUBY_GEMS and adding at begin of $PATH variable  /web/redmine/gems/bin to correctly run all this gems. There were installed bundler-1.0.21, i18n-0.4.2, mysql-2.8.1, rack-1.1.3, rake-0.9.2, rails-2.3.14 and thin-1.3.1 - to use later as a webserver. 

So redmine was installed in started via webrick on port 3000 for testing. And I've got problem with templates. On some pages like calendar I've got errors like this.

Processing CalendarsController#show (for 178.176.50.23 at 2012-01-11 23:11:39) [GET]

Parameters: {"controller"=>"calendars", "action"=>"show"}
Rendering template within layouts/base
Rendering calendars/show

ActionView::TemplateError (incompatible character encodings: ASCII-8BIT and UTF-8) on line #13 of app/views/calendars/show.html.erb:
10: </fieldset>
11:
12: <p style="float:right;">
13: <%= link_to_previous_month(@year, @month) %> | <%= link_to_next_month(@year, @month) %>
14: </p>
15:
16: <p class="buttons">

app/helpers/calendars_helper.rb:16:in `link_to_previous_month'
app/views/calendars/show.html.erb:13:in `block in _run_erb_app47views47calendars47show46html46erb'
app/views/calendars/show.html.erb:3
<internal:prelude>:10:in `synchronize'
/usr/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/usr/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/usr/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'

Rendering /home/brainstorm/redmine/public/500.html (500 Internal Server Error)

 

After some time of debug I've found that template engine gets UTF-8 strings as raw strings. (Here is some inormation about function force_encoding: http://yehudakatz.com/2010/05/05/ruby-1-9-encodings-a-primer-and-the-solution-for-rails/),

If I add force_encoding to strings inside erb templates I get correct work. So strings were not "marked" as UTF-8 strings. After debugging and analisys I've understood that mysql adapter gem works with strings incorrectly. And there is mysql2 adapter which can do all we need with strings from database correct. In the documentation of fresh mysql2 gem was written the following:

If you need to use mysql2 with Rails versions < 3.1 make sure and specify gem "mysql2", "~> 0.2.7" in your Gemfile

So... I've just installed mysql2 using command

gem install mysql2 -v 0.2.7

Added to redmine database.yml mysql2 as adapter and got all working properly.

Now Redmine runs on Ruby 1.9.2.

Comments

Submitted by Victor (not verified) on

I've got the same problem (with a lot of others, of course :), and thanks to you, my redmine is working now.

Submitted by Serge A. Salamanka (not verified) on

This article helped me with Redmine installation. I missed the editing of adapter setting in database.yml and got the errors described. After I changed the adpater to mysql2 everything runs ok.

Thanks very much!