Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Heroku Buildpack: Run

Run custom commands during the build process.


This buildpack allows specifying custom scripts or other commands that will be run during the build process. If any command exits with a non-zero status code, the build is aborted.


Using the script

By default, the buildpack looks for a script named in the root directory of your app. So, you can do the following:

echo -e '#!/bin/bash\necho "Hello World"' >
chmod +x
git add && git commit
git push heroku master

The above example will print Hello World during the build.

Using the BUILDPACK_RUN config variable

Alternatively to using, you can specify custom commands in the BUILDPACK_RUN config variable:

heroku config:set BUILDPACK_RUN='echo "Hello World"

The above example will print Hello World during the build.

You can also specify multiple commands by separating them with colons:

heroku config:set BUILDPACK_RUN='echo "Hello World":uname -a:./ foo bar

In the above example, the buildpack will execute the following commands in sequence:

  1. echo "Hello World"
  2. uname -a
  3. ./ foo bar

Loading config variables

By default, the app's config variables are only available as files in a specific directory in the build environment (see ENV_DIR below). You can load all these config variables as environment variables by setting the BUILDPACK_RUN_LOAD_CONFIG config variable:

heroku config:set BUILDPACK_RUN_LOAD_CONFIG=1

Now, all the app's config variables will be available to your commands as environment variables.

If you want to prevent certain config variables from being loaded as environment variables (for example, to prevent overwriting native environment variables), you can specify them in the BUILDPACK_RUN_LOAD_CONFIG_SKIP config variable (separated by colons):


In the above example, the config variables named FOO, BAR, and BAZ will not be loaded as environment variables. Note that this may be especially useful for config variables like PATH that you might not want to overwrite in the build environment.

Default environment variables

The following special environment variables are always available to your commands:

  • BUILD_DIR: your app's root directory in the build environment
  • CACHE_DIR: directory that persists between builds and can be used as a cache
  • ENV_DIR: directory containing the app's config variables as files


Licensed under the MIT License. See file.