Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
389 views
in Technique[技术] by (71.8m points)

rubygems - Bypassing rack version error using Rails 2.3.5

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...