pypa / pip

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

"pip install --quiet" hides conflict information #10519

Open mitchhentges opened 3 years ago

mitchhentges commented 3 years ago

Description

When using --quiet to hide some pip output, it no longer elaborates on which specific packages are conflicting:

$ pip install --constraint constraint.txt click==7.1.2 --quiet
ERROR: Cannot install click==7.1.2 because these package versions have conflicting dependencies.
ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies
$ pip install --constraint constraint.txt click==7.1.2
ERROR: Cannot install click==7.1.2 because these package versions have conflicting dependencies.

The conflict is caused by:
    The user requested click==7.1.2
    The user requested (constraint) click==7.0

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies

Expected behavior

I'd expect output that looks something like this:

$ pip install --constraint constraint.txt click==7.1.2 --quiet
ERROR: Cannot install click==7.1.2 because these package versions have conflicting dependencies.

The conflict is caused by:
    The user requested click==7.1.2
    The user requested (constraint) click==7.0

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies

pip version

21.2.3

Python version

3.6

OS

Fedora 34

How to Reproduce

$ echo "click==7.0" > constraint.txt
$ pip install --constraint constraint.txt click==7.1.2 --quiet

Output

No response

Code of Conduct

DiddiLeija commented 3 years ago

I consider this is a feature request to the error messages.

pradyunsg commented 3 years ago

This is probably a "bug" more than a "feature request" -- however, fixing this will be very involved.

The cause for this is very clear: the conflict information is logged at the info level to avoid being presented in red.

https://github.com/pypa/pip/blob/76cdf8f7e1cfe7024e0fe51c31694a3863bf91ae/src/pip/_internal/resolution/resolvelib/factory.py#L695

That's because we'd gotten fairly clear user feedback that the entire error message being in red was not-great, so we moved away from using logger.critical for it. The fix for this is NOT to use logger.critical but to decouple our output coloring from the level of the output, which... is gonna be a decently involved fix.

mitchhentges commented 3 years ago

That makes sense, thanks for the background. Also, unrelated:

Cheers :beers:

healthy-pod commented 2 years ago

@pradyunsg @DiddiLeija I opened #10763 to fix this issue and it's ready for review.