-
Notifications
You must be signed in to change notification settings - Fork 127
Suppress pip root user warning by conditionally skipping ensurepip in installer scripts #369
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -51,7 +51,13 @@ chmod +x ../python $PYTHON_MAJOR $PYTHON_MAJOR_DOT_MINOR $PYTHON_MAJORMINOR pyth | |||||||||||||||||||
|
|
||||||||||||||||||||
| echo "Upgrading pip..." | ||||||||||||||||||||
| export PIP_ROOT_USER_ACTION=ignore | ||||||||||||||||||||
| ./python -m ensurepip | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if [ -d "$(./python -c 'import site; print(site.getsitepackages()[0])')/pip" ]; then | ||||||||||||||||||||
| echo "pip directory found in site-packages, skipping ensurepip." | ||||||||||||||||||||
| else | ||||||||||||||||||||
| echo "pip directory not found, running ensurepip..." | ||||||||||||||||||||
| ./python -m ensurepip | ||||||||||||||||||||
| fi | ||||||||||||||||||||
| ./python -m pip install --upgrade --force-reinstall pip --disable-pip-version-check --no-warn-script-location | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
Comment on lines
61
to
62
|
||||||||||||||||||||
| ./python -m pip install --upgrade --force-reinstall pip --disable-pip-version-check --no-warn-script-location | |
| # Verify pip is functional before attempting to upgrade | |
| if ./python -m pip --version >/dev/null 2>&1; then | |
| ./python -m pip install --upgrade --force-reinstall pip --disable-pip-version-check --no-warn-script-location | |
| else | |
| echo "Error: pip is not functional after ensurepip. Aborting pip upgrade." | |
| exit 1 | |
| fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pip directory check uses command substitution without proper error handling. If the Python command fails (e.g., site module not available, or
getsitepackages()returns an empty list), the script will continue with potentially incorrect behavior due toset -ebeing active. The command should be wrapped with error handling or the result should be validated.Consider using a safer approach: