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

Warn users about shadowed entrypoint scripts on installation #7228

Open
chrahunt opened this issue Oct 17, 2019 · 4 comments
Open

Warn users about shadowed entrypoint scripts on installation #7228

chrahunt opened this issue Oct 17, 2019 · 4 comments
Labels
C: scripts How scripts and entry points are managed state: awaiting PR Feature discussed, PR is needed type: feature request Request for a new feature

Comments

@chrahunt
Copy link
Member

As mentioned by @pradyunsg in #7209 (comment).

What's the problem this feature will solve?

When installing a package using --user with entrypoints/scripts that shadow another executable, there can be problems if that executable is on PATH before the new executable. This is especially true for Python scripts when something changes about the actual function that gets imported (like moving pip._internal:main to pip._internal.main:main).

This is one of the causes behind #5599.

Describe the solution you'd like

On installation of a package, identify the executables that were created for scripts/entrypoints. For each executable, determine if it is the executable that would be found given a normal invocation of the name (or basename, for scripts that end with something in PATHEXT). If not, then trace a warning to the user like

The package {package name} installed the script {script name} to {location}, but we found another script with the same name at {location} which is ahead of it on your PATH. If you want to execute the new script then invoke it directory or update your PATH.

Alternative Solutions

  • Do nothing

Additional context

@chrahunt chrahunt added state: awaiting PR Feature discussed, PR is needed C: scripts How scripts and entry points are managed type: feature request Request for a new feature labels Oct 17, 2019
@chrahunt chrahunt changed the title Warn users about overridden entrypoint scripts on installation Warn users about shadowed entrypoint scripts on installation Oct 17, 2019
@pfmoore
Copy link
Member

pfmoore commented Oct 17, 2019

determine if it is the executable that would be found given a normal invocation of the name

Just to note, such a check can only ever be approximate. Cases like shell aliases, or shells hashing commands, would defeat this check. I'm not saying that we couldn't do such a check, just that we need to be cautious about how we report the result. (We could even get false positives - a shell function could mean that the user does pick up the new wrapper, even though our check identified an issue). We had a similar debate a while ago (#6414) because not all shells expand ~ the same way in PATH.

@chrahunt
Copy link
Member Author

Agreed. All of these kinds of warnings are only meant to cover the 90% case, to help reduce bad user experience (and our support workload).

We're tracking reporting possible shell path hashing issues in #6863. I think there will be overlaps with the situations matched with this heuristic, and in those cases printing both should be okay, IMO.

@pfmoore
Copy link
Member

pfmoore commented Oct 17, 2019

Sounds good to me.

@pradyunsg
Copy link
Member

Thanks for filing this @chrahunt!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: scripts How scripts and entry points are managed state: awaiting PR Feature discussed, PR is needed type: feature request Request for a new feature
Projects
None yet
Development

No branches or pull requests

3 participants