Rpj
Rpj

Reputation: 6080

How to prevent stale references of gems in shared bundle folder

/home/ec2-user/app/shared/bundle/ruby/2.0.0/gems/ 

The above folder post a rails app deployment via capistrano contains different versions of the same gem

e.g. foo-1.0.0 and foo-1.0.1 and foo-1.0.2

since I upgraded my gem two times (reflected via Gemfile.lock) after original deployment. This is causing the application to not work properly since its not clear which gem takes precedence and gets loaded for the application. How can I make sure that while deploying bundle via capistrano that stale references from the previous version are removed.

Upvotes: 2

Views: 225

Answers (1)

Winfield
Winfield

Reputation: 19145

When you use a persistent, shared bundle directory between deploys, you're trading speed for issues like this.

You have two options:

  1. Manually clear the shared bundle directory when you upgrade gem
  2. Use a bundle directory within the release

If you want to use a non-shared bundle directory within the release directory, you will only have the current version of gems and supporting files installed. However, you will have to install all bundled gems every time you deploy.

I would opt for #1 and clear out the bundle install directory when the deploy has a problem and fails. #2 is safer and always works, but is slower.

Upvotes: 1

Related Questions