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

Improve the error message when bundled pip cannot be found #1720

Merged
merged 1 commit into from
Dec 12, 2024

Conversation

edmorley
Copy link
Member

@edmorley edmorley commented Dec 12, 2024

The Python stdlib bundles a copy of pip, which the buildpack uses to bootstrap the real pip installation. This copy of pip should always exist, and thus not finding it is treated as an internal error.

However, via Honeycomb I discovered one app that manages to hit this case regardless, and when it does so, the error message is not the "internal error" error message, but instead a Bash unbound variable error like:

-----> Using Python 3.9.20 specified in .python-version
-----> Using cached install of Python 3.9.20
/tmp/buildpack/lib/utils.sh: line 33: bundled_pip_wheel_list[0]: unbound variable

My guess for why pip is not being found in this case is that the app's Git repo may have a broken/EOL Python install committed to it (which doesn't include the ensurepip module), which tricks the cache restoration into thinking it can re-use the cache.

I will be adding an explicit warning/error for finding an existing .heroku/python/ directory in the app in a later PR, however, for now this change:
(a) fixes the display of the internal error message,
(b) adds more debugging output to the error message so that I can confirm my theory as to the root cause for this app.

Towards #1710.
GUS-W-17386432.

@edmorley edmorley added the bug label Dec 12, 2024
@edmorley edmorley self-assigned this Dec 12, 2024
@edmorley edmorley marked this pull request as ready for review December 12, 2024 15:45
@edmorley edmorley requested a review from a team as a code owner December 12, 2024 15:45
The Python stdlib bundles a copy of pip, which the buildpack uses to
bootstrap the real pip installation. This copy of pip should always
exist, and thus not finding it is treated as an internal error.

However, via Honeycomb I discovered one app that manages to hit this
case regardless, and when it does so, the error message is not the
"internal error" error message, but instead a Bash unbound variable
error like:

```
-----> Using Python 3.9.20 specified in .python-version
-----> Using cached install of Python 3.9.20
/tmp/buildpack/lib/utils.sh: line 33: bundled_pip_wheel_list[0]: unbound variable
```

I believe the reason for pip not being found in this case is that the
app source has a broken/EOL Python install committed to it (which
doesn't include the `ensurepip` module), which tricks the cache
restoration into thinking it can re-use the cache.

I will be adding an explicit warning/error for finding an existing
`.heroku/python/` directory in the app in a later PR, however, for now
this change:
(a) fixes the display of the internal error message,
(b) adds more debugging output to the error message so that I can
    confirm my theory as to the root cause for this app.

Towards #1710.
GUS-W-17386432.
@edmorley edmorley force-pushed the bundled-pip-error-message branch from 8e8f09e to de550dc Compare December 12, 2024 16:12
@edmorley edmorley enabled auto-merge (squash) December 12, 2024 16:14
@edmorley edmorley merged commit 8a27499 into main Dec 12, 2024
7 checks passed
@edmorley edmorley deleted the bundled-pip-error-message branch December 12, 2024 16:16
@heroku-linguist heroku-linguist bot mentioned this pull request Dec 12, 2024
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.

bundled_pip_wheel_list[0]: unbound variable error if a broken Python install exists in app source
2 participants