Using Bundler Groups on Heroku

Bundler groups are commonly used to specify which dependencies of your application are needed in a given environment. You may have something like this in your Gemfile:

 group :test do
   gem "rspec"
 end

Using the "test" group in this case allows you to specify the gems that are needed to test your application.

Since you won’t need these gems in production, you can speed up installation by ignoring the "test" group. Bundler provides this ability through the --without option:

 bundle install --without test

You can currently access this functionality on Heroku by setting the BUNDLE_WITHOUT config var in your application.

Starting today we are going to default BUNDLE_WITHOUT to "development:test" on all new applications.

If necessary, you can change this value for your application by changing the BUNDLE_WITHOUT config var:

 heroku config:add BUNDLE_WITHOUT="foo:bar"

Existing applications will not be affected by this change to the default. If you have an existing application and would like to take advantage of this feature, simply set the BUNDLE_WITHOUT config var to an appropriate value.

We hope that this new default will help to reduce the deploy time of your Heroku applications. Please give it a try and let us know your thoughts!

Update: You can find the most recent information about this topic in our Managing Gems with Bundler article on DevCenter.

Browse the blog archives or subscribe to the full-text feed.