Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buildpack warnings when building in /app ("rm: cannot remove '/app': Read-only file system") #9

Closed
edmorley opened this issue Mar 1, 2021 · 0 comments · Fixed by #10

Comments

@edmorley
Copy link
Contributor

edmorley commented Mar 1, 2021

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:

rm -rf $BUILD_DIR

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.

This was referenced Apr 1, 2021
czerwinskilukasz1 pushed a commit to czerwinskilukasz1/subdir-heroku-buildpack that referenced this issue May 25, 2022
Since otherwise once Heroku builds are run from `/app`, builds
will output warnings due to the `/app` root being read only:

```
remote: -----> Subdir buildpack app detected
...
remote:        cleaning build dir /app
remote: rm: cannot remove '/app': Read-only file system
```

Fixes timanovsky#9.

Co-authored-by: Alexey Timanovsky <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant