uv
                                
                                 uv copied to clipboard
                                
                                    uv copied to clipboard
                            
                            
                            
                        Should `uv sync` remove extraneous packages?
It currently does not, while uv pip sync does. This would also affect whether uv remove removes all extraneous packages, or has to do extra work to only remove the affected packages.
In brief, I think we should:
- Change sync to always remove extraneous packages. This is the common understanding on sync.
- Implement an opt-out option for removal during sync, e.g. --allow-extra-packages
- Update uv removeto allow extraneous packages by default, only removing the relevant dependency tree
uv sync now removes extraneous packages by default, which you can opt-out with --no-clean.
Currently uv add and uv run do not ever remove from the environment, and so uv remove should, for consistency, only remove the affected packages. An alternative approach to 3 is to have all project commands, uv run, uv add, and uv remove, always clean the virtual environment, which would simplify things and doesn't seem necessarily problematic.
I don't think they should always clean the virtual environment. I think it's too common for people to manually manage packages in Python and without an explicit sync it seems excessive for us to purge extraneous packages. Changing remove to be more clearly scoped by default seems like a more intuitive user experience.
Update uv remove to allow extraneous packages by default, only removing the relevant dependency tree
Does this mean: uv remove foo uninstalls foo, or uninstalls foo and its dependencies?
My current vote is that it uses the same semantics as uv run, and we add an --exact argument to enable exact syncing. But I would also be okay shipping with the current behavior.
I think it's too common for people to manually manage packages in Python and without an explicit sync it seems excessive for us to purge extraneous packages.
IIUC, uv's top level commands do some automations to keep your workspace in sync between lockfile, pyproject.toml and venv.
I think who wants manually manage packages could use low level commands, i.e. uv pip uninstall in this case.
I think we made a decision on this — we have a toggle now.
For anyone coming here after not finding the switch when looking at --help: It is called --inexact.