Skip to content

Conversation

@edmorley
Copy link
Member

@edmorley edmorley commented Dec 8, 2025

Currently for historic reasons the buildpack adds the current working directory to PATH, due to adding an empty colon-delimited segment before the default Ubuntu PATH.

This can cause errors if the app has a script/binary in its root directory that has the same name as a command the buildpack tries to run. For example, on Honeycomb I've seen internal errors when the buildpack attempts to locate the bundled pip, due to the tail command being run not being the command we expected:

-----> Installing pip 25.2, setuptools 70.3.0 and wheel 0.45.1
./tail: line 1: heroku: command not found

 !     Internal Error: Unable to locate the Python stdlib's bundled pip.

Removing this customisation of PATH is a breaking change, but safer in the long run (and also matches the Python CNB behaviour).

Any apps that call a script or binary that's in the root directory of their app from bin/pre_compile or bin/post_compile hook (or any other subprocess called by the buildpack) will now need to do so via an explicit relative path. For example, use ./my_command not my_command when calling the script/binary.

This change doesn't affect:

  • app behaviour at run-time (only during the build)
  • apps that call scripts in a subdirectory (eg foo/my_command)
  • apps that already use a relative path for scripts in the app's root directory (eg ./my_command)

GUS-W-20472356.

Currently for historic reasons the buildpack adds the current working
directory to `PATH`, due to adding an empty colon-delimited segment
before the default Ubuntu `PATH`.

This can cause errors if the app has a script/binary in its root
directory that has the same name as a command the buildpack tries
to run. For example, on Honeycomb I've seen internal errors when
the buildpack attempts to locate the bundled pip, due to the `tail`
command being run not being the command we expected:

```
-----> Installing pip 25.2, setuptools 70.3.0 and wheel 0.45.1
./tail: line 1: heroku: command not found

 !     Internal Error: Unable to locate the Python stdlib's bundled pip.
```

Removing this customisation of `PATH` is a breaking change, but safer
in the long run.

Any apps that call a script or binary that's in the root directory
of their app from `bin/pre_compile` or `bin/post_compile` hook
(or any other subprocess called by the buildpack) will now need to do
so via an explicit relative path. For example, use `./my_command`
not `my_command` when calling the script/binary.

This change doesn't affect:
- app behaviour at run-time (only during the build)
- apps that call scripts in a subdirectory (eg `foo/my_command`)
- apps that already use a relative path for scripts in the app's
  root directory (eg `./my_command`)

GUS-W-20472356.
@edmorley edmorley self-assigned this Dec 8, 2025
@edmorley edmorley added the bug label Dec 8, 2025
@edmorley edmorley marked this pull request as ready for review December 8, 2025 11:25
@edmorley edmorley requested a review from a team as a code owner December 8, 2025 11:25
Copy link
Contributor

@dzuelke dzuelke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume there is a test somewhere that triggers the invocation

@edmorley edmorley merged commit f3b29ee into main Dec 8, 2025
7 checks passed
@edmorley edmorley deleted the rm-path-cwd branch December 8, 2025 11:30
@edmorley
Copy link
Member Author

edmorley commented Dec 8, 2025

I assume there is a test somewhere that triggers the invocation

This PR added a cat script to one of the fixtures, and cat is called multiple times throughout the buildpack (more so than tail, hence using cat since it's less likely to get refactored away in the future), which causes the tests to fail prior to the change in this PR.

@edmorley
Copy link
Member Author

edmorley commented Dec 8, 2025

And the CWD during hook execution is tested via using a relative path here:

@heroku-linguist heroku-linguist bot mentioned this pull request Dec 9, 2025
@edmorley
Copy link
Member Author

edmorley commented Dec 9, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants