简体   繁体   中英

Rack gem being shadowed using Apache2 and Passenger

We deploy multiple apps using Apache2 and Passenger (v3.0.9). App Foo is a Rails 3.0.11 app and app Bar is a Rails 3.1.3 app. Both apps use bundler to manage their dependencies. From my understanding of the Passenger documentation, Passenger and Bundler work as expected to load the necessary dependencies for each app. Foo depends on Rack 1.2.4 and Bar depends on Rack 1.3.5.

When Bar is deployed, and bundle install gets run (via Capistrano), Rack 1.3.5 gets installed. And suddenly Foo gets the following Passenger error:

Gem::LoadError - You have already activated rack 1.3.5, but your Gemfile requires rack 1.2.4. Using bundle exec may solve this.

The message is trying to be helpful, but I'm not sure exactly where bundle exec should be run. I've also tried doing a bundle install --path vendor/cache as recommended elsewhere, but that didn't seem to help.

I can uninstall Rack 1.3.5, but at Bar's peril. And another solution is to just upgrade Foo to Rails 3.1.x, but I'd like to understand what is going wrong here, since it is likely we'll have apps running different versions in the future.

I am in a similar situation: one Rails 3.0.11 app and a Rails 3.2.8 app under the same domain on the same server.

Using Capistrano for deployment.

In the config/deploy.rb I have:

require 'bundler/capistrano'

during "cap deploy", the bundler recipe runs:

cd {app_path}/releases/{release} && bundle install --gemfile {app_path}/releases/{release}/Gemfile --path {app_path}/shared/bundle --deployment --quiet --without development test

this (--path and --deployment) manages a per app gem repository in

{app_path}/shared/bundle/ruby/{ruby_version}/gems

so in one Rail 3.0.11 App I have rack-1.2.4 and rails-3.0.11 while in the 3.2.8 APP I have rack-1.4.1 and rails-3.2.8 . Both gemsets are beautifully separated.

Maybe you can clean up these gemset repositories.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM