uv
uv copied to clipboard
`uv pip sync` fails to clear environment when given an empty requirements list
I have a use case where several different environments are being updated with uv pip sync, and some of those environments may legitimately have a desired end state of "just a Python runtime with no extra packages" (the packages that are installed into those environments are platform dependent, and on some platforms there are no additional packages needed).
When trying to clear those environments, uv pip sync simply reports "No requirements found" and exits immediately instead of synchronising the environment with the requirements list as desired.
I can work around this, but being able to reliably clear an environment from outside was a key motivation for switching from pip-sync to uv pip sync (due to https://github.com/jazzband/pip-tools/issues/2103)
Hi! The request makes sense but this is a tough one for user experience because people can pass all sorts of requirements sources and we've seen people confused when they accidentally have an empty set of requirements. Do you think we should add a flag to opt-in to this behavior?
Yeah, an opt-in flag like --allow-clear would make sense (I assumed the UX benefit was the reason for the current behaviour)
Here's a proof of concept: https://github.com/astral-sh/uv/pull/4517
That would definitely work for my use case, and the name --allow-empty-requirements seems clear enough.