My deploy failed, saying "error: Could not read COMMIT_HASH." What should I do?

Your app may fail to build with an error message including:

1
2
3
4
5
error: Could not read COMMIT_HASH

fatal: revision walk setup failed

fatal: reference is not a tree: COMMIT_HASH

(Where COMMIT_HASH is a long hexadecimal number)

This error is caused by pushing from a shallow clone. Those are typically used by CI and CD platforms in order to optimize build times.

To solve this problem, update your build script to run this command before pushing to Aptible:

1
git fetch --unshallow || true

Note that if your CI platform uses an old version of git, --unshallow may not be available. In that case, you can try fetching a number of commits large enough to fetch all commits through to the repository root, thus unshallowing your repository:

1
git fetch --depth=1000000