pypa / pip

The Python package installer
https://pip.pypa.io/
MIT License
9.48k stars 3.01k forks source link

Provide CLI users with a bash command to update their PATH #11109

Open burt23 opened 2 years ago

burt23 commented 2 years ago

What's the problem this feature will solve?

When installing a new package I'm coming across error messages that the script doesn't exist in my PATH. It would be really nice if a bash command was supplied to add the command to my .bash_profile, .profile, .zshrc or equivalent shell profile.

The errors could also be consolidated to read all the following packages where not found in your PATH, run the following to update your PATH. This would cut down on the logs which currently repeat the same PATH warning several times

Describe the solution you'd like

Consolidate all warnings for "script SCRIPT_NAME installed at LOCAL_LOCATION which is not on PATH" into a single error message. Provide a user with a single command to update their .profile and PATH with the proper values for all offending scripts when installing a new package

Alternative Solutions

Detect what shell a user is using and attempt to automatically update their path for them. Alternatively provide users with a prompt if they want pip to attempt updating their local rc file.

Additional context

WARNING: The script {SCRIPT_NAME} is installed in {PATH_TO_LOCAL_BIN} which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

Code of Conduct

pfmoore commented 2 years ago

Why a bash command? I assume that the intention would be that the command was generic enough to work for most bourne-compatible shells, but what about users of other shells like fish, or Windows users, who should set their path via the GUI?

I think it's better to explain to the user what to do, but leave it to them to understand how to do it for their particular system.

If someone came up with a way of describing what the user should do that wasn't specific to a particular shell/environment, then maybe that would be a possibility. But honestly, I doubt it's possible to do that sufficiently robustly (and we've seen users blindly copy other commands which are supposed to be suggestions, and raise bugs when they don't work).