Update for Rails 3: Rails 3 and Bundler: Deploying gems using Capistrano
Thought I’d share this because I had a lot of trouble figuring out how and where to run the “rake gems:install” when deploying with Capistrano. I wanted it to automatically deploy the gems when I call “cap deploy:migrations” – this is done by installing the gems right after update_code, like this:
# config/deploy.rb after "deploy:update_code", "gems:install" namespace :gems do desc "Install gems" task :install, :roles => :app do run "cd #{current_release} && #{sudo} rake gems:install" end end
Some of the examples I’ve seen use “cd #{current_path}” but I don’t think this would work as the “current” symlink hasn’t been updated at the time the “update_code” task is run. That’s why I use “current_release”.
Also others use “rake RAILS_ENV=production gems:install” but I can’t see why you should have to use RAILS_ENV here. If I’m wrong, please correct me.
Some of the links I found when trying to get this to work: