Capistrano and bundle config

When you use capistrano and you need a custom bundler config in your Rails app, you have the problem, that it gets lost after each update.

The solution to this problem is to move the .bundle folder in your rails app, to the shared folder in your capistrano environment. Then you tell capistrano to link the .bundle to the shared folder after each update.

  • First, move your Rails.root/.bundle to ../../shared/.bundle
  • Add a rake task to Rails.root/config/deploy.rb:
namespace(:bundle) do
  desc "Symlinks your machine specific bundle to your rails app"
  task :symlink, :roles => :app do
    run <<-CMD
      ln -nfs #{shared_path}/.bundle #{release_path}/.bundle
  • tell capistrano to invoke the bundle:symlink task after symlinking your freshly deployed realase. In your Rails.root/config/deploy.rb:
after "deploy:symlink", "bundle:symlink"