Skip to content
Run custom commands during the build of a Heroku app
Branch: master
Clone or download
Pull request Compare This branch is 10 commits behind weibeld:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Heroku Buildpack: Run

Run custom commands during the build process.


This buildpack allows to execute arbitrary commands on the build dyno during the build process by sourcing one or more files with Bash commands.



Add the buildpack to your app:

heroku buildpacks:add

Create the file in the root directory of your app, for example:

echo "Hello World"

Now push your app to Heroku as usual. The commands in will be executed during the build.

Optional: use a different filename

If you want to use another filename than, then you can specify this filename in the app config variable BUILDPACK_RUN. For example, if your file is called

heroku config:set

Optional: use multiple files

You can specify multiple files to BUILDPACK_RUN by separating them with colons. For example, if you want to source the files and in this order, then set your BUILDPACK_RUN as follows:

heroku config:set BUILDPACK_RUN=""

Additional Information

  • The working directory of the shell in which your commands will be executed is the root directory of your app
  • The paths of the files specified to BUILDPACK_RUN must be relative to the root directory of your app
  • You can use the command exit 1 in your files to abort the build
  • The following build-specific shell variables are available to your command files:
    • BUILD_DIR: path to the root directory of your app on the build dyno
    • ENV_DIR: the directory holding all your app's config variables as files
    • CACHE_DIR: directory whose content persists across builds of your app


Licensed under the MIT License. See file.

You can’t perform that action at this time.