Heroku’s support for running multiple buildpacks against a single application now has first-class support in the Heroku Toolbelt.

Change effective on 07 May 2015

Heroku’s support for running multiple buildpacks against a single application now has first-class support in the Heroku Toolbelt.

When you git push heroku, Heroku’s slug compiler prepares your code for execution by the Heroku dyno manager. At the heart of the slug compiler is a collection of scripts called a buildpack. Buildpacks usually focus on a single language or framework, such as Ruby or Node.js, but many applications need support for more than one language. The most common example is using the Node.js buildpack to prepare client-side Javascript assets for a server-side application written in Ruby or another language.

By default, Heroku will choose the best buildpack for your app automatically. But in many cases, you will need to explicitly define the buildpack. For a Ruby application, the command is this (the URL for the buildpack will vary based on the language):

$ heroku buildpacks:set https://github.com/heroku/heroku-buildpack-ruby.git

Then if you need to add an additional buildpack, such as the Node.js buildpack, you may do so with the following command:

$ heroku buildpacks:add --index 1 https://github.com/heroku/heroku-buildpack-nodejs.git

This will insert the Node.js buildpack before the Ruby buildpack in the buildpack execution order. You can view the complete list of buildpacks with this command:

$ heroku buildpacks
=== nameless-brushlands-4859 Buildpack
1. https://github.com/heroku/heroku-buildpack-nodejs.git
2. https://github.com/heroku/heroku-buildpack-ruby.git

The last buildpack in the list should be the primary buildpack. It will be used to determine the application’s process types.

For more information on using the heroku buildpacks command, see the Heroku Dev Center.