Bypassing rack version error using Rails 2.3.5
Asked Answered
J

9

8

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.

Jute answered 29/11, 2009 at 6:49 Comment(2)
Maybe it helps to ask their support to upgrade rack (and rails)?Coh
dhofstet - sadly nope - they're pretty reluctant to do anything to actually help solve this problem. They can migrate you to new servers that use a more recent version of rails/rack/passenger which I'm told will solve the problem.Kermitkermy
S
0

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.

Springe answered 29/11, 2009 at 8:50 Comment(2)
rake gems:unpack:dependencies didn't put rack in vendor/gems, any ideas why?Patrilocal
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 :PKermitkermy
T
6

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.

Tervalent answered 13/2, 2010 at 7:32 Comment(0)
E
4

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.

Exegetic answered 17/12, 2009 at 8:15 Comment(0)
M
1

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.

Mycorrhiza answered 30/11, 2009 at 7:7 Comment(0)
W
1

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.

Warfourd answered 22/3, 2010 at 15:27 Comment(1)
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.Jute
F
1

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

Fulmer answered 25/1, 2012 at 17:36 Comment(0)
S
0

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.

Springe answered 29/11, 2009 at 8:50 Comment(2)
rake gems:unpack:dependencies didn't put rack in vendor/gems, any ideas why?Patrilocal
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 :PKermitkermy
N
0

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

Nial answered 11/12, 2009 at 15:14 Comment(1)
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.Jute
D
0

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

I guess that solves it.

Delacruz answered 18/12, 2009 at 0:5 Comment(0)
A
0

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

Aliciaalick answered 22/12, 2009 at 16:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.