Skip to content
This repository has been archived by the owner on Mar 10, 2021. It is now read-only.

Buildpack incompatible with building in /app ("cp: cannot stat '/app/!(tmp)': No such file or directory") #12

Open
edmorley opened this issue Mar 9, 2021 · 1 comment

Comments

@edmorley
Copy link

edmorley commented Mar 9, 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.

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.

Once this change comes into effect this buildpack will error like so:

remote: -----> Python app detected
remote: cp: cannot stat '/app/!(tmp)': No such file or directory

This is because the buildpack tries to move the contents of /app to a temporary location, followed by moving BUILD_DIR (which is now /app) into /app.

To reproduce, the new behaviour can be enabled manually (ahead of it being the new default), using:

heroku labs:enable build-in-app-dir -a my_app_name

To fix, the file moves (at both the start and end of the build) need to be put behind a conditional that first checks if BUILD_DIR is already /app:

# Directory Hacks for path consistiency.
APP_DIR='/app'
TMP_APP_DIR=$CACHE_DIR/tmp_app_dir
# Copy Anvil app dir to temporary storage...
mkdir -p $TMP_APP_DIR
deep-mv $APP_DIR $TMP_APP_DIR
# Copy Application code in.
deep-mv $BUILD_DIR $APP_DIR
# Set new context.
ORIG_BUILD_DIR=$BUILD_DIR
BUILD_DIR=$APP_DIR

deep-mv $BUILD_DIR $ORIG_BUILD_DIR
deep-mv $TMP_APP_DIR $APP_DIR

@dbrgn
Copy link
Owner

dbrgn commented Mar 9, 2021

Hi @edmorley. Thanks for the information! I haven't touched this repository in years, it's not maintained anymore. README links to a fork that used to be active, not sure if it still is.

I'll archive the repo to avoid future confusion.

Cheers!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants