Hi
I'm on the team that maintains Heroku's build system and official buildpacks, and wanted to let you know about a future incompatibility with this buildpack (which is one of the most popular of the sub directory/monorepo style buildpacks).
The directory in which the Heroku build system performs builds is currently a path like/tmp/build_<hash>
.
In the near future this path will be changing to /app
so that the build-time and run-time app locations are the same path - in order to resolve a number of long standing bugs, and reduce the number of hacks buildpacks have to use to work around non-relocatable languages/toolchains.
One side-effect of this build directory change is that it will no longer be possible to rm -rf $BUILD_DIR
since that will now be equivalent to rm -rf /app
, and due to the way slugs are mounted inside a dyno, the /app
directory is read-only (not the contents of the directory, only the directory listing itself).
As such once this change comes into effect this buildpack will output Read-only file system
warnings like so:
remote: -----> Subdir buildpack app detected
remote: -----> Subdir buildpack in frontend
remote: creating cache: /tmp/codon/tmp/cache
remote: created tmp dir: /tmp/codon/tmp/cache/subdirXF9Kh
remote: moving working dir: frontend to /tmp/codon/tmp/cache/subdirXF9Kh
remote: cleaning build dir /app
remote: rm: cannot remove '/app': Read-only file system
remote: recreating /app
remote: copying preserved work dir from cache /tmp/codon/tmp/cache/subdirXF9Kh to build dir /app
remote: cleaning tmp dir /tmp/codon/tmp/cache/subdirXF9Kh
remote: -----> Discovering process types
remote: Procfile declares types -> (none)
remote:
remote: -----> Compressing...
remote: Done: 191B
remote: -----> Launching...
remote: Released v6
Due to this line:
The build won't actually fail, since bin/compile
doesn't use bash exit on error (#8). Conveniently, the build output result will actually still be correct, since the rm -rf $BUILD_DIR
will still remove all of the other files in /app
even though it fails to remove /app
itself.
As such, this is more of a warning than an error, though it might lead people to think the buildpack isn't working.
In order to prevent the warning, the buildpack needs to instead delete only the contents of the directory, not the directory root - I'll open a PR for that now.