views:

7401

answers:

9

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.

+1  A: 

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.

mtyaka
rake gems:unpack:dependencies didn't put rack in vendor/gems, any ideas why?
J. Pablo Fernández
I am having the same problem as the questioner and when I try to run `rake gems:unpack:dependencies` is when I get the error message that he describes... ie I can't unpack the dependencies... because it's complaining about rack being the wrong version :P
Taryn East
+1  A: 

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.

anon
A: 

Did you find any solution? This was not an answer i think, because problem starts after unpacking rack 1.0.1.

desperate_cry
A: 

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).

ragaskar
I ended up freezing rails 2.3.4 so that my dependency was rack 1.0.0. Kinda sucked to have to stay off edge, but it solved the problem.
Matt
+2  A: 

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.

Henry
A: 

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

I guess that solves it.

someone
A: 

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).

j t
Sadly, it's the 12 March and still not working for me...
Taryn East
+5  A: 

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.

Mike Deck
+1  A: 

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.

Mike
I think this worked because Dreamhost has since updated their gems since this question was created to include Rack 1.0.1. This is largely not an issue anymore due to that update.
Matt