-
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
Special Case Install Warning for Literal Package Name "requirements.txt" #9908
Comments
Sounds like a good feature to me, feel free to send in a PR! As a side note, you might want to change the instruction to the following instead; pip emits a more useful message if the user forgets
|
Thanks for the feedback, I will definitely be working on this. I had one question though. Do you think it is worth it to bring in true path detection (like The benefit of actual path detection (ie: searching the file system) is that it picks up more cases of the issue such as the one you pointed out ( The downside is the added complexity of bringing in the What do you think? |
I would just do a literal string match to |
Added a special warning for users who accidentally do `pip install requirements.txt` and forget the `-r` flag. Issue pypa#9908
Added entry to news/ directory documenting change. Issue pypa#9908
@uranusjr Not sure if you were notified, but I submitted a pull request that needs a maintainer's permission to run through the CI system. Thanks for all your help on this one. |
I don't like how error is presented as is, but this will improve once the error is migrated to the more user friendly rich error format (see #10421). Regardless, this issue can be issue as the resolving PR has been merged (and released into the wild too!) almost three years ago?! |
*nudge* This issue can be closed as the resolving PR has been merged and published ~3 years ago. |
What's the problem this feature will solve?
I work in a technical support / system administration role for students and an extremely common issue they have is accidentally misusing the
pip install
command like this:They of course want to install the packages listed in
requirements.txt
, and not the literal package namedrequirements.txt
(there is none). As such they should be doingpip install -r requirements.txt
(adding the-r
flag), but this is not immediately obvious for beginners.Describe the solution you'd like
I understand that you can't really hold people's hand for everything, and at a certain point, the user is responsible for investigating issues themselves, but this one keeps coming up and I think it is a rather low hanging fruit. I think it would be reasonable to include a special case error message when attempting to install a package that is literally named
requirements.txt
.Alternative Solutions
This sort of diagnostic is frequently issued by compilers when the developer attempts to write something very close to an idiomatic expression. For example, C compilers will generally warn when using an unknown symbol that is 1 letter away from a common symbol (
kread
: no such symbol, did you meanread
?).Additional context
pip install -r requirements.txt
is such a common idiom, and in my experience is frequently mis-remembered aspip install requirements.txt
. For this reason, I suggest special casing the standard error message and adding an additional line suggesting the idiomatic use.I would be happy to tackle this issue myself (it should be a relatively trivial fix), but I wanted to know what people think before getting to work. Thanks for your time.
The text was updated successfully, but these errors were encountered: