Skip to content
This repository was 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

@edmorley

Description

@edmorley

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions