-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Prevent pip install pip install #11898
Prevent pip install pip install #11898
Conversation
e713c5c
to
100732c
Compare
x-ref pypi/support#451 I'm down to do this, if no one else has concerns. :) |
Shouldn't be a problem if |
d4a2947
to
6629510
Compare
7e5a089
to
5ff87a3
Compare
c1e506c
to
275af31
Compare
Co-authored-by: Daniel Hollas <danekhollas@gmail.com>
275af31
to
e5d795b
Compare
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.
@MiguelGuthridge LGTM, but I am not a pip maintainer so cannot help with landing this. :-)
"\n".join( | ||
[ | ||
"Likely incorrect command: pip install pip install ...", | ||
f"Did you mean \"pip install {' '.join(args[2:])}\"?", | ||
'To install the "install" package, run ' | ||
'"pip install install" separately', | ||
] | ||
) |
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 join
call is unnecessary since you can use implicit string join instead.
@@ -2560,3 +2560,65 @@ def test_install_pip_prints_req_chain_pypi(script: PipTestEnvironment) -> None: | |||
f"Collecting python-openid " | |||
f"(from Paste[openid]==1.7.5.1->-r {req_path} (line 1))" in result.stdout | |||
) | |||
|
|||
|
|||
def test_prevent_pip_install_pip_install(script: PipTestEnvironment) -> None: |
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.
These two tests can be combined into one with pytest.mark.parametrize
.
Just closing a loop here: pypi/support#451 was closed, with |
It looks like this issue has been resolved. |
Resolves #11484.
If a user pastes an install command into their terminal, but has already typed
pip install
beforehand, this currently results inpip
installing theinstall
package, which is likely never their intention given thatinstall
is a nearly useless package to prevent typosquatting.This appears to be a common mistake given that the
install
package has around 30000 installs on most weekdays.This PR adds a check to prevent users from running
pip install pip install package
andpip install install package
, which should hopefully save users some time and frustration, since there won't be a need to follow their mistaken command up with apip uninstall install
to rectify their mistake.Note that it is still possible to install the
install
package usingpip install install
by itself or by specifying it as not being the first package.As far as I'm aware, this feature shouldn't require documentation, but I'm happy to write some if required (let me know where since I can't think of a good place for it).
This is my first PR to
pip
, so please let me know if there's anything I've overlooked! Thanks!