Handling Deploys with Gem Bundler
Published:
November 14, 2009
The best method of usage for Gem Bundler we have found is to check in only your Gemfile and the gem cache dir, ignoring the rest in .gitignore:
vendor/bundler_gems/environment.rb
vendor/bundler_gems/gems
vendor/bundler_gems/specifications
Now we have our known working .gem files checked in we can ensure that on deploy only these will be used on the server by passing Bundler the cached flag when deploying with Capistrano:
after 'deploy:update_code', 'gems:bundle'
namespace :gems do
task :bundle, :roles => :app do
run "cd #{release_path} && gem bundle --cached"
end
end
Otherwise Bundler will look for updated gems and download them when you have not locked your Gemfile gems to specific versions. Stinging you big time, especially when APIs change on point releases..
Anyhow, the reason you would want to do this as opposed to just checking in the whole vendor/bundler_gems dir is that you won’t dirty up you history with thousand line commits when upgrading gems.