Skip to content

Cache handling error when requirements.txt is no longer symlinked #1675

@edmorley

Description

@edmorley

As reported in heroku/buildpacks#42 by @abingham:

In short: I replaced a symlink in my repo with a normal file, and now my deployments fail with the error:

cp: not writing through dangling symlink '/tmp/codon/tmp/cache/.heroku/requirements.txt'
 !     Push rejected, failed to compile Python app.
 !     Push failed

requirements.txt is the file that used to be a symlink and is now a file.

I can reproduce this myself.

The cause are the dubious copies here:

if [[ ! -f "$CACHE_DIR/.heroku/requirements.txt" ]]; then
# This is a the first build of an app (or the build cache was cleared). Since there
# are no cached packages, we only need to store the requirements file for next time.
cp -R "$BUILD_DIR/requirements.txt" "$CACHE_DIR/.heroku/requirements.txt"
else
# IF there IS a cached directory, check for differences with the new one
if ! diff "$BUILD_DIR/requirements.txt" "$CACHE_DIR/.heroku/requirements.txt" &>/dev/null; then
output::step "Requirements file has been changed, clearing cached dependencies"
# if there are any differences, clear the Python cache
# Installing Python over again does not take noticably more time
cp -R "$BUILD_DIR/requirements.txt" "$CACHE_DIR/.heroku/requirements.txt"

This issue amongst others will be fixed by the upcoming cache refactor :-)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions