HOWTO: Redmine 3.0 with Debian Wheezy, Nginx, Thin

I spent a few hours troubleshooting a problem with Thin when I upgraded from Redmine 2.5 to Redmine 3.0 on a Debian Wheezy server. I found a solution that’s worked for me. I’m not confident enough with Ruby and this setup to make a HowTo on the Redmine wiki, but I found next to nothing on this specific problem when searching the web, so I figure it’s important to post this in case it helps anyone else.

I’m running Redmine on Debian Wheezy with Nginx and Thin. I’m also running Redmine on another Wheezy server with Apache (and mod_passenger, I think). The latter upgrade to Redmine 3.0 went fine, but when I ran the same steps on the thin/nginx server, I was getting a Bad Gateway 502 error from nginx and found this in the thin logs.

!! Unexpected error while processing request: uninitialized constant Rack::MethodOverride::REQUEST_METHOD

Yet, when I ran Redmine with webrick (per Redmine’s installation instructions), it worked fine. Since it worked fine with webrick and on my other server, it seemed like the problem was at the Thin layer.

This Stack Overflow issue was the closest I could find, though it was with a different Rack application. The problem was a mismatch between the Rack version and the one required by the application.

I couldn’t find Redmine-specific examples (hence this post), but this one Redmine guide did say “Rack 1.0.1. Version 1.1 is not supported with Rails 2.3.5”.

Finally, the Stack Overflow issue linked to this issue in the Passenger tracker which pointed me towards the answer:

Your system has two Rack versions installed. One is version 1.5.0, installed by APT, and is located in /usr/lib/ruby/vendor_ruby. The other one is version 1.6.0, installed by RubyGems, and is located in /var/lib/gems/2.1.0/gems/rack-1.6.0.

Before Passenger loads your app, Passenger calls require “rack”. Because /usr/lib/ruby/vendor_ruby is in Ruby’s $LOAD_PATH, Passenger loads the Rack 1.5.0 library installed by APT.

However Sinatra requires Rack 1.6.0 or later…

This was my problem. When I installed Redmine 2.5, I ran `apt-get install thin`. It pulled in ruby-rack 1.4.1 as a dependency. This “conflict” wasn’t a problem in Redmine 2.5, which has “rack (~> 1.4.5)” in Gemfile.lock — the versions are close enough. However, Redmine 3.0 has “rack (~> 1.6)” in Gemfile.lock… hence the error I was seeing, as Rack 1.4.1 installed via apt was probably being loaded in place of the 1.6.1 Gem.

I tried to `apt-get remove ruby-rack`, but it was going to remove thin as well. (And I checked the Jessie repos, but its ruby-rack is still only 1.5.2.) I identified two solutions:

  1. Uninstall ruby-rack and thin via apt, and reinstall thin separately (this worked)
  2. Create a dummy .deb using equivs to install thin via apt without really installing ruby-rack (I didn’t bother trying this, since the first solution worked)

To install thin separately, first I removed it and ruby-rack whiling marking a couple other dependencies as manually installed and keeping the /etc/init.d/thin file…

apt-get remove ruby-rack thin
apt-get install ruby-eventmachine ruby-daemons # not sure if this was necessary or advisable, just a guess

Then, following the thin installation instructions, I was able to install the gem:
apt-get install ruby-dev build-essential
gem install thin
# Update the path in /etc/init.d/thin from /usr/bin/thin (apt) to /usr/local/bin/thin (gem)
perl -pi -w -e 's/\/usr\/bin\/thin/\/usr\/local\/bin\/thin/g' /etc/init.d/thin

I was able to start thin again (`service thin start`), but I was getting a new error for which I found the solution here: add thin to your Gemfile.

So, somewhat reluctantly, I opened up Gemfile in the Redmine root directory and in between a couple other gem lines I added the line:
gem "thin"

Then, I restarted thin, and Redmine was working again!

Things I don’t like about this solution or am unsure of:

  • Editing Redmine’s Gemfile sucks, because I’ll lose that change on every update and I’ll have to re-apply it. Since it’s a simple one-liner and updates are every few months, it works for me for now.
  • I don’t know yet whether those other apt thin dependencies are required or might cause other conflicts in the future… but since it’s working now, and I’m not familiar with Ruby, I don’t feel like spending more time to experiment and find out.
  • Maybe I should have looked at other options beside thin, like Puma or Passenger? But since I already had Thin working before, I just decided to see if I could salvage it rather than exploring alternatives. Maybe thin isn’t the best option in this circumstance though, but it’s working.
  • I’m assuming that /etc/init.d/thin was there and working because it was leftover from the apt thin installation (and because I didn’t `apt-get purge`). That may have been lucky that the init script happens to work (as far as I can tell for now) with the thin gem…

Hopefully this can help anyone else using Redmine(3.0)/Debian/Nginx/Thin seeing that error. I’d be happy to share configuration and fresh installation instructions once I have some confidence that this approach is sane, and in particular once I have a better solution than modifying the Gemfile.

Leave a comment

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

One thought on “HOWTO: Redmine 3.0 with Debian Wheezy, Nginx, Thin”