Skip to content

Commit 99e5ac3

Browse files
committed
Error if we're not the first buildpack
I had someone using the `heroku/metrics` buildpack which writes to `.profile.d` directory running before this buildpack. Because this buildpack deletes everything at the root, including things from other build packs, the change was not preserved even though it looked like it executed correctly. I'm proposing if we detect that another buildpack has executed (i.e. if the `.profile.d` folder is not empty), that we abort and error with a helpful message: ``` [main 2446fe5] empty Enumerating objects: 1, done. Counting objects: 100% (1/1), done. Writing objects: 100% (1/1), 185 bytes | 185.00 KiB/s, done. Total 1 (delta 0), reused 0 (delta 0), pack-reused 0 remote: Compressing source files... done. remote: Building source: remote: remote: -----> Building on the Heroku-20 stack remote: -----> Using buildpacks: remote: 1. heroku/metrics remote: 2. https://github.com/schneems/subdir-heroku-buildpack#schneems/don-t-delete-profile-d remote: -----> HerokuRuntimeMetrics app detected remote: -----> Setting up .profile.d to automatically run metrics agent... remote: -----> Subdir buildpack app detected remote: -----> Subdir buildpack in api remote: Another buildpack seems to have run remote: before the subdir buildpack. This remote: may cause unexpected problems. remote: remote: Ensure '$ heroku buildpacks' lists remote: the subdir buildpack first and try remote: again. remote: ! Push rejected, failed to compile Subdir buildpack app. remote: remote: ! Push failed remote: Verifying deploy... remote: remote: ! Push rejected to still-harbor-23981. $ heroku buildpacks === still-harbor-23981 Buildpack URLs 1. heroku/metrics 2. https://github.com/schneems/subdir-heroku-buildpack#schneems/don-t-delete-profile-d ```
1 parent f531487 commit 99e5ac3

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

bin/compile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@ if [ -f $ENV_DIR/PROJECT_PATH ]; then
1212
PROJECT_PATH=`cat $ENV_DIR/PROJECT_PATH`
1313
if [ -d $BUILD_DIR/$PROJECT_PATH ]; then
1414
echo "-----> Subdir buildpack in $PROJECT_PATH"
15+
16+
if [ -n "$(ls -A $BUILD_DIR/.profile.d 2>/dev/null)" ]; then
17+
echo " Another buildpack seems to have run"
18+
echo " before the subdir buildpack. This"
19+
echo " may cause unexpected problems."
20+
echo ""
21+
echo " Ensure '$ heroku buildpacks' lists"
22+
echo " the subdir buildpack first and try"
23+
echo " again."
24+
exit 1
25+
fi
26+
1527
echo " creating cache: $CACHE_DIR"
1628
mkdir -p $CACHE_DIR
1729
TMP_DIR=`mktemp -d $CACHE_DIR/subdirXXXXX`

0 commit comments

Comments
 (0)