Search code examples
ruby-on-railscapistranobundlebundler

Bundler via Capistrano on production seems to always unnecessarily reinstall everything


For some reason bundler isn't just installing needed gems not already installed. Instead it's re-installing everything in my Gemfile. Is there are way to get it to only install needed gems (they it works for me in development mode).

Capistrano 2.6.0
Bundler 1.0.12
Ubuntu 10.04 server 32-bit

Task Snippet:

task :bundle_gems, :roles => :app do
  run "cd #{deploy_to}/current && bundle install --path vendor/gems RAILS_ENV=production"
end

Solution

  • Bundler actually comes with a Capistrano recipe that does everything for you. Add this to config/deploy.rb:

    require "bundler/capistrano"
    

    Remove your self-written bundle_gems task and Capistrano will automatically bundle your gems, optimised for deployment.

    There's a bit more information here: http://gembundler.com/deploying.html