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

pip exits with success despite incompatible constraint #6969

Closed
cjolowicz opened this issue Sep 3, 2019 · 3 comments
Closed

pip exits with success despite incompatible constraint #6969

cjolowicz opened this issue Sep 3, 2019 · 3 comments
Labels
auto-locked Outdated issues that have been locked by automation resolution: duplicate Duplicate of an existing issue/PR type: support User Support

Comments

@cjolowicz
Copy link
Contributor

Environment

  • pip version: 19.2.3
  • Python version: 3.7.4
  • OS: macOS 18.7.0

This was also reproduced using docker run python:3.

Description

pip installs a package with broken dependencies, if a constraints file specifies an incompatible version. An error message is shown, but the exit code is 0.

For example, environs 5.2.1 requires marshmallow>=2.7.0, but pip installs it with marshmallow 2.6.0 if the latter is specified in a constraints file.

Expected behavior

pip should not install the package, and exit with failure.

How to Reproduce

  1. Create constraints.txt with marshmallow==2.6.0
  2. Create requirements.txt with environs==5.2.1
  3. Run pip install -r requirements.txt -c constraints.txt

Output

$ docker run --rm -ti python:3 sh
# python -V
Python 3.7.4
# pip -V
pip 19.2.3 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)
# uname -a
Linux 4d4f16cc965f 4.9.184-linuxkit #1 SMP Tue Jul 2 22:58:16 UTC 2019 x86_64 GNU/Linux
# echo marshmallow==2.6.0 > constraints.txt
# echo environs==5.2.1 > requirements.txt
# pip install -r requirements.txt -c constraints.txt
Collecting environs==5.2.1 (from -r requirements.txt (line 1))
  Downloading https://files.pythonhosted.org/packages/5f/c9/6b576b8b374dfe78d9435988e6a53497822f31b9da5bdd446343ad1a4d1b/environs-5.2.1-py2.py3-none-any.whl
Collecting marshmallow==2.6.0 (from -c constraints.txt (line 1))
  Downloading https://files.pythonhosted.org/packages/33/44/c3bdd4222909b6452ebe5c028ea5dbe7e9409307b3b933026218c677fcf1/marshmallow-2.6.0-py2.py3-none-any.whl (44kB)
     |████████████████████████████████| 51kB 729kB/s
Collecting python-dotenv (from environs==5.2.1->-r requirements.txt (line 1))
  Downloading https://files.pythonhosted.org/packages/57/c8/5b14d5cffe7bb06bedf9d66c4562bf90330d3d35e7f0266928c370d9dd6d/python_dotenv-0.10.3-py2.py3-none-any.whl
ERROR: environs 5.2.1 has requirement marshmallow>=2.7.0, but you'll have marshmallow 2.6.0 which is incompatible.
Installing collected packages: marshmallow, python-dotenv, environs
Successfully installed environs-5.2.1 marshmallow-2.6.0 python-dotenv-0.10.3
# echo $?
0
@triage-new-issues triage-new-issues bot added the S: needs triage Issues/PRs that need to be triaged label Sep 3, 2019
@chrahunt chrahunt added resolution: duplicate Duplicate of an existing issue/PR S: awaiting response Waiting for a response/more information type: support User Support labels Sep 14, 2019
@triage-new-issues triage-new-issues bot removed the S: needs triage Issues/PRs that need to be triaged label Sep 14, 2019
@chrahunt
Copy link
Member

This is essentially the same as #988 (see also: #5137).

Pip figures out requirements on a first-encountered basis (though that is subject to change without notice). When the requirements file and constraints file are parsed, we end up with environs==5.2.1 as a requirement and marshmallow==2.6.0 as a constraint. When environs is being processed, marshmallow is noticed as a dependency and the existing entry (marshmallow==2.6.0) is marked as a requirement, and the existing version is the one used for installation. I think using the user-provided value (even if just as a constraint) is probably the most correct behavior we can have here.

The error that is traced is the same that would be traced for a plain pip install environs==5.2.1 marshmallow==2.6.0 or separate invocations like pip install environs==5.2.1 && pip install marshmallow==2.6.0.

@pradyunsg
Copy link
Member

This was added in #5000. The reason the exit code isn't 1, is backwards compatibility.

If you want to programically know that this is happening, you want to run pip check.

@no-response
Copy link

no-response bot commented Oct 14, 2019

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

@no-response no-response bot closed this as completed Oct 14, 2019
@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Nov 13, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Nov 13, 2019
@pradyunsg pradyunsg removed the S: awaiting response Waiting for a response/more information label Mar 17, 2023
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 resolution: duplicate Duplicate of an existing issue/PR type: support User Support
Projects
None yet
Development

No branches or pull requests

3 participants