Question

I'm currently on Dreamhost attempting to run a Rails 2.3.5 app.

Here is the situation, Dreamhost's servers have Rails 2.2.2 installed. Of course, I can't update a shared host's rails version, so I froze my Rails in vendor. Rails 2.3.5 requires the rack v1.0.1 gem. Dreamhost uses the rack v1.0.0 gem. So when I try to define:

config.gem "rack", :version => "1.0.1"

I get:

can't activate rack (~> 1.0.1, runtime) for [], already activated rack-1.0.0 for []

So what I really need to do is bypass my app's request to use 1.0.1, and use Dreamhost's 1.0.0. Does anyone know how to configure this? Is it even possible? Thanks for the help.

Was it helpful?

Solution

You will almost always want to unpack the gems that your application depends on into the vendor folder. You can do that with this rake command:

rake gems:unpack:dependencies

This will create a folder vendor/gems under your application's root folder and unpack all of the gems that you declared with the config.gem command into it.

This will not only solve your problem with mismatching rack versions, but also make sure that you are using the exact same versions of gems in production as you are using in development, which can prevent many potential headaches in the future.

OTHER TIPS

Dreamhost has addressed this issue on their support wiki now.

http://wiki.dreamhost.com/Ruby_on_Rails#Rails_2.3.5_-_Rack_1.0_already_activated_.28fix.29

From that page:

When using Rails 2.3.5 you will get a problem from Passenger saying Rack 1.0.1 cannot be loaded because Rack 1.0 is already activated.

One way to solve this is by freezing Rails and unpack the Rack gem into vendor/gems/rack-1.0.1

Once Rails and Rack are in the vendor/rails and vendor/gems/rack-1.0.1 you must modify action_controller in file: vendor/rails/actionpack/lib/action_controller.rb

In line numbers 34 and 35 must be commented out and add the following to load rack from vendor/gems

   load "#{RAILS_ROOT}/vendor/gems/rack-1.0.1/lib/rack.rb"

The end result should look something like this:

   #gem 'rack', '~> 1.0.1'
   #require 'rack'
   load "#{RAILS_ROOT}/vendor/gems/rack-1.0.1/lib/rack.rb"

The real problem is that Passenger already loads Rack 1.0 and I believe Passenger must load 1.0.1 in order for this hack to go away.

rake gems:unpack:dependencies doesn't allow you to unpack rake into your vendor/gems folder.

For the Dreamhost issue, you must do what Matt said. Freeze rails to 2.3.4.

rake rails:freeze:gems VERSION=2.3.4

Dreamhost uses an older version of Passenger which preloads rack 1.0.0. You can't load rack 1.0.1 once rack 1.0.0 has been preloaded. Therefore, the latest version of rails possible for DH is Rails 2.3.4 and Rack 1.0.0.

I ran into the same problem when I tried upgrading to 2.3.5.

I wonder what server you are on that still runs Rails 2.2.2? I thought Dreamhost had moved everybody to 2.3.4 by now. I complained with them 3 months ago and they upgraded Passenger on my server the day after so I could install the current Rails version. So I'd recommend you to file a support ticket if Rails 2.3.5 is vital for your app. But there weren't many changes between 2.3.4 and 2.3.5, so chances are your app will run just as well on 2.3.4. Did you try running it on vendored 2.3.4?

This isn't about a missing gem, it's about a gem that is being required twice with mismatching versions. rake gems:unpack:dependencies doesn't fix that (I tried).

I suspect it's a problem with Dreamhost's Passenger version again. My server (buenosaires) has Passenger 2.2.5. Latest Passenger version is 2.2.7.

A simple gem update of rack didn't work for me because it seems that Rails 2.3.5 wants Rack 1.0.1 specifically. So, when I did a gem update rack -v=1.0.1, Rails 2.3.5 started right up.

Apparently this whole thing with Rails wanting rack 1.0.1 is a small dependency requirement bug in actionpack which can be solved fairly easily.

For me it was enough to edit vendor/rails/actionpack/lib/action_controller.rb on line 34 from gem 'rack', '~> 1.0.1' to gem 'rack', '~> 1.0' and the problem went away.

See: https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/3685-actionpack-235-gem-declares-incompatibility-with-rack-110

Dreamhost is updating Rack and Rails: http://www.dreamhoststatus.com/2009/12/21/ruby-gem-updates/

I guess that solves it.

I think that at the moment the best would be to unfreeze everything and use what is on dreamhost. They have currently rails 2.3.4 and if you can wait a day or two - dreamhost is upgrading rails gems to 2.3.5 (it should have been upgraded already yesterday on 21st of december - but for some reason they didn't explain they are still on 2.3.4).

FWIW, I can confirm that freezing the gem does not solve the problem; in fact, where before my deploy was exploding (using DH's Rack 0.3.0, somehow!), now my spin-up blows up with the same error seen above. Perhaps it's finally time to move my toy/proof of concept app to 'real' hosting if I want to get any work done.

UPDATE: My server was upgraded to Rack 1.0.1 on Dec 24th 2009, solving the issue for me. If you are still experiencing problems on your account I would recommend messaging support; they were fairly responsive in my case (with emails, not action, but for the price you really can't have it all).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top