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

Improve Error Messages on EnvironmentErrors when installing #5239

Merged
merged 3 commits into from
Apr 17, 2018

Conversation

pradyunsg
Copy link
Member

Fixes #5237

@pradyunsg pradyunsg added the type: enhancement Improvements to functionality label Apr 15, 2018
@pradyunsg pradyunsg added this to the 10.0.1 milestone Apr 15, 2018
@pradyunsg pradyunsg requested a review from a team April 15, 2018 14:28
@pradyunsg
Copy link
Member Author

Same question as always: Do we want tests?

@pfmoore
Copy link
Member

pfmoore commented Apr 15, 2018

We always want tests :-)

More seriously, a test that we don't say "use -v" when the user is using -v seems reasonable. As does a test that we don't suggest -v on a permission error (and getting that test right on both Windows and Unix should be interesting, given that Windows and Unix have such different permission models - I'm genuinely unsure whether by omitting the EPERM test you've changed the meaning of the message on Windows).

@pv
Copy link

pv commented Apr 15, 2018

Checked against my testcase, it now prints:

Collecting six
  Using cached six-1.11.0-py2.py3-none-any.whl
Installing collected packages: six
Consider using the `--user` option  or  check the permissions

But note that it still doesn't say the installation failed. I think it's important the output contains an explicit statement that the installation was not successful.

if not show_error:
message_parts.append(
"To view error traceback, increase verbosity "
"passing --verbose."
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a native speaker, but "increase verbosity by passing --verbose"?

@benoit-pierre
Copy link
Member

Not showing the original exception and asking the user to re-run with -v seems backward to me. What if it was a transient error? IMHO, in trying to hard to print a "helpful" message, pip is hiding useful information. Even with -v the output is not that useful:

Installing collected packages: six

Could not install packages due to an error. Consider using the `--user` option or check the permissions. To view error traceback, increase verbosity by passing --verbose.

Cleaning up...

I don't know where pip is installing the package, and the original exception is not shown either, so I have not idea which directory I should check the permissions.

Contrast that with the last line when pip is trying to update its self-check state file:

PermissionError: [Errno 13] Permission denied: '[...]/venv/pip-selfcheck.json'

That one is useful.

@pradyunsg
Copy link
Member Author

Not showing the original exception and asking the user to re-run with -v seems backward to me.

@benoit-pierre I agree. Thanks for your input on this. :)

I'm genuinely unsure whether by omitting the EPERM test you've changed the meaning of the message on Windows

@pfmoore It's trivial to add it back but I think EPERM isn't the right error code here (based on here). None the less, we're still printing the error message so, we should be fine?

As for tests, I'll take a look tomorrow.


I've gone ahead and redone this entire logic. I've moved out the code into a separate function -- that should make testing it easier. It's also resulting in either the string representation of the error or the entire Traceback showing up in the terminal (not both). Further, it's also unconditionally mentioning that an error occurred.

@pfmoore pfmoore mentioned this pull request Apr 16, 2018
# If we won't show a traceback, tell the user how to get it.
if not show_traceback:
parts.append(
"To view error traceback, increase verbosity by passing --verbose."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just show the traceback if we think it's needed, rather than asking the user to rerun? Although honestly I think this is too much hand holding - if there's not enough information in the displayed output, adding --verbose is always the advice, so why call it out specifically here?

But I'd rather someone just make a decision on this - I don't want to debate wording to the point where we don't at least put some information in the user's hands.

…tall.

This fixes various issues with the current logic and splits out the
message generation into a separate unit-test-able function.

Improvements:
- Does not not-print any information in some cases
- Mentions original error message, or entire traceback if verbose.
- In case of permission/access errors, suggests the user to use --user
  and/or check permissions
@pradyunsg
Copy link
Member Author

I'll add tests in a subsequent PR. Happy to let this go in as is.

@pfmoore pfmoore merged commit 9875055 into pypa:master Apr 17, 2018
@pradyunsg pradyunsg deleted the fix/5237 branch April 17, 2018 18:05
@pradyunsg pradyunsg restored the fix/5237 branch May 27, 2018 09:38
@pradyunsg pradyunsg deleted the fix/5237 branch May 27, 2018 10:08
@lock
Copy link

lock bot commented Jun 2, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jun 2, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation type: enhancement Improvements to functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pip 10.0.0 fails silently if it cannot install due to missing write permissions
4 participants