Rails 3.1 Compatibility


I am trying to deploy rails 3.1 application on DreamHost.
First, I had this error.

You have already activated rack 1.2.1, but your Gemfile requires rack 1.3.2. Consider using bundle exec.

DreamHost support told me to remove config.ru.

But that caused another error.

no such file to load – dispatcher

Does anybody know how to fix this problem?


Hey Sam,

I think you want to put this in your gem file:
gem ‘rack’, ‘1.2.1’

then in your terminal window type: bundle install

This doesn’t work. Rails 3.1 requires 1.3.2. When is Dreamhost going to upgrade to Rails 3.1?

Hi :slight_smile:

Hmm normally you should delete the “Gemfile.lock” file within the main folder of your application and then you can launch a “bundle install”.

The first error you had : "You have already activated rack 1.2.1, but your Gemfile requires rack 1.3.2. Consider using bundle exec."
Normally rises because you already installed rack 1.2.1 gem and bound it to your application. The “bundle install” simply bound gems to your applications by creating the “Gemfile.lock” which is then used by the server to know which gems to use for your application (that what the keyword “activated” means).

By the way, if you simply want to update the Gemfile.lock you should run “bundle update” instead of “bundle install”.

Bye :slight_smile:

Hi Sam,

Did you ever get this working? I’m currently in exactly the same situation :frowning:

Hi Fetimo,

As I said once you upload your Rails 3.1 application on your server, you have to delete “gemfile.lock” then relaunch bundle install. That’s the easiest way to get it works. Well of course for a 3.1 application you have to get rack 1.3.2 or higher so, if you want you can still force this version to be installed by adding this line to your gemfile:

gem ‘rack’, ‘1.3.2’

Ok but that’s not the only error you’ll get if you are on a shared host. And for all the one who want to deploy a Rails 3.1 application on Dreamhost and that are not able to install their own version of ruby and passenger, here’s the temporary fix:

In fact you’ll receive a syntax error. This syntax error is no big deal. In fact, it’s due to the new Ruby 1.9.2 hash syntax. So far you were used to write hashes like this:
{ :key => “value” }

But Ruby 1.9.2 supports a new syntax which is:
{ key: “value” }

And the problem is that Ruby 1.8.7 doesn’t support this syntax, and guess what, the Dreamhost’s Passenger application is based on Ruby 1.8.7. So… If you want to get rid off this syntax error just search for all the new hash syntax (normally they appear in the error thrown by Passenger) and replace them by the old syntax. Ruby 1.9.2 supports both so there’ll be no compatibility errors.

I know it’s a little bit boring, but… I’m sure it’s quicker than trying to install your own version of Ruby and get it works. Believe me I tried on a shared server solution and I had an awful headeach by the end of the day.

Of course, after that, don’t forget to precompile your assets: http://guides.rubyonrails.org/asset_pipeline.html#in-production

And! Yeah in less than a morning, thanks to this solution, I got my Rails 3.1 Application up and running: www.society2be.com (you’ll surely notice that I’m French so… in advance, I beg your pardon for my poor English).

I already asked Dreamhost about Ruby 1.9.2, they told me that they planed to update their Ruby Version but not in the immediate timeframe. They asked me to use RVM locally and gave me this link: http://wiki.dreamhost.com/RVM but… first I already tried with no success, second it’s for VPS or dedicated server and I’m on a shared one so…

I hope It’ll help some people :slight_smile:


Ok… After a while the error appeared again… That’s because it seems that when Passenger wakes up it first loads (or only) the system gems… As the rack system gem is 1.2.1 and rails 3.1 application needs rack 1.3.2… there’s an incompatibility problem.

If you’re on a dedicated server or on a VPS, no problem just install the rack gem at the system level. If… like me you’re on a shared server, then so far I’ve found no great solutions… and I’ll be glad to hear one.

In bundler, can’t remember the exact process, there is a way to package the gems you need into your app then “deploy” them to your app from there.

Not only does it solve the problem you are having, it ensures you have the right versions.

It’s not the most ideal solution, but it works for me on my deployed apps.

Yeah, I know the process, that’s:

$ bundle install --deployment

I already tried and it didn’t solve the problem, cause I’m not sure the problem comes from the gems, I’d say it rather comes from passenger, but I may be wrong… In face the problem is that it seems that passenger firstly loads system’s gems when he wakes up. So the first hit on my site web raises the error (if no one went there for a while), and a F5 just works fine…

And what about you rjhancock, have you a rails 3.1 application? Did you manage to “kill” all the errors you got? Cause so far I didn’t have the problem with Rails 3.0 applications so…

Sorry for the late response. I’ve deployed a 3.0 app like that, haven’t tried the 3.1 app just yet.

I’m actually writing a new 3.1 app for a non profit for handling application/fee processing and will be posting it within the next few months.

Hi again :slight_smile:

Okay so… I finally upgraded my account to a VPS one and now I’m able to deploy both 3.0 and 3.1 rails app for just $5 more per month. I think that’s the best solution if you want to deploy whatever you want on your hosting plan.

If anyone gets trouble to deploy 3.1 Rails applications on a VPS server, well, I’ll be glad to help :wink:

I have a VPS and would like to deploy a Rails 3.1 app. I would like to use rvm and capistrano. Do yo have instructions on how you made this work?

Hi :slight_smile:

Ok so… For RVM I followed this guide : http://wiki.dreamhost.com/RVM which is a really good one. Everything worked well for me but if you have some problems following it, please, feel free to ask me for help ;).

Concerning Capistrano I’m not using it right now but I will within few days… I’ll try to write a little walkthrough for you (if you didn’t manage to make it run).

By the way, there’s also a guide for capistrano: http://wiki.dreamhost.com/Capistrano I will use it for sure!

I’m not sure if this works for Rails 3.1 (to be fair, I don’t use Rails), but when Rails 3 was fresh, one of DreamHost’s customers wrote up this nifty article, which may help with Rails 3.1 (Cap and Bundler both addressed!)