Read more

Capistrano: exclude custom bundle groups for production deploy

Daniel Straßner
September 12, 2016Software engineer at makandra GmbH

Capistrano is by default configured to exclude the gems of the groups development and test when deploying to the stages production and staging. Whenever you create custom groups in your Gemfile, make sure to exclude these, if they should not be deployed to the servers. The gems of these groups might not be loaded by rails, however, the deployment process will take longer as the gems will be downloaded and installed to the server.

Illustration book lover

Growing Rails Applications in Practice

Check out our e-book. Learn to structure large Ruby on Rails codebases with the tools you already know and love.

  • Introduce design conventions for controllers and user-facing models
  • Create a system for growth
  • Build applications to last
Read more Show archive.org snapshot

e.g. to exclude the groups cucumber and deploy, add the following to config/deploy/production.rb and config/deploy/staging.rb respectively:

set :bundle_without, %w{development test cucumber deploy}.join(' ')

Be aware, that gems that belong to two groups, are only excluded, when both of the groups are excluded, e.g. to exclude rspec in the following example, you will have to bundle without test and cucumber:

group :test, :cucumber do
  gem 'rspec'
end
Posted by Daniel Straßner to makandra dev (2016-09-12 09:58)