question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add option to cause non-zero exit code if `pip install` caused conflicting packages

See original GitHub issue

What’s the problem this feature will solve?

I’m writing tooling around pip, and I would like it to “fail fast” when an environment has conflicting packages.

Describe the solution you’d like

In #7744, it’s discussed how it’s currently not feasible to block a pip install from happening if will cause conflicts.

However, in today’s behaviour, pip install does an internal equivalent of pip check at the end to check for conflicts. My feature request here is for that internal pip check to return a non-zero exit code if conflicts are detected.

This allows scripts that run pip install <package> --return-exit-code-if-conflicts-are-caused-please to stop immediately after conflicts are caused.

Alternative Solutions

I’m currently running pip check after each pip install, which is essentially doubling the amount of “conflict-checking” that’s happening.

Additional context

Thanks!

Code of Conduct

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
pfmoorecommented, Sep 28, 2021

Can you describe the specific use cases and benefits you expect to get from this? The cost of a pip check is pretty minor (certainly compared to the cost of an install) and all you are really saving here is the extra command.

In addition, we’d be changing the meaning of the return code - at present I believe that a non-zero return code means that pip didn’t install anything, and left the environment unchanged. I’m pretty sure there will be people who rely on that fact, so we either break their workflows, or (as in your example) we add a flag that changes the meaning of the return code, which would cause confusion. And you’d still need to distinguish between “install failed, no change” and “install succeeded, but pip check failed”, so you’d need a different return code.

If we were designing pip from scratch, this might be a reasonable feature to have, but given where we are now, I’m not sure it’s worth it. But as I say, if the uses you’re thinking of are compelling, that might change my mind.

0reactions
pradyunsgcommented, Sep 30, 2021

I’m ambivalent – “meh” is probably the best way to summarise my position.

I think the actual change of making this fail is straightforward:

  • add a raise InstallationError("AAAA! CONFLICT! AAAA!") in the right place, and we’re done.
  • --no-warn-conflicts which will need to be mutually exclusive to this.

One good thing to do though, would be to abort prior to making the installation + doing the wheel builds; which can save a bunch of work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Non-zero exit code (1) - unable to install packages in pycharm
As a workaround, you can downgrade pip to 20.2.4 or use the terminal for installing packages. To downgrade pip on Windows, close PyCharm...
Read more >
pyvenv-3.4 returned non-zero exit status 1 - Stack Overflow
I got a solution installing python-virtualenv ... '--upgrade', '--default-pip']' returned non-zero exit status 1 zsh: exit 1 python3 -m venv .venv.
Read more >
tox 3.3.0 - PyPI
checking your package installs correctly with different Python versions and ... If True, a non-zero exit code from one command will be ignored...
Read more >
Cluster cancels Python command execution due to library ...
When you install a conflicting version of a library, such as ipython, ipywidgets, numpy, scipy, or pandas to the PYTHONPATH, then the Python...
Read more >
pip dependency resolver does not currently - You.com | The search ...
It is dangerous when running pip install downgrades packages without asking you. ... one) option would be just returning non-zero exit code for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found