You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
uv remove --group any_group any_package. All deps are removed. #9012
Was "six" removed from the pyproject.toml, or just the virtual environment?
I had three packages in my virtual environment: six, pillow and lxml.
With the command uv remove --group gr2 lxml
I wanted to remove only one package
Expected behavior - the package will be removed from all files (tom and lock) and from the virtual environment
In fact - the package is removed from all files (toml and lock) AND all packages are removed from the virtual environment.
In this regard, all dependencies need to be reinstalled.
Is this how it should work?
It's not really clear from uv remove --group gr2 lxml what we should do when we re-sync the project. We can't just remove lxml -- it might still be a requirement, or a requirement of one of your requirements. So we just re-sync with the project's default dependencies, which excludes the group.
The behavior for optional dependencies seems to differ here. When using uv remove, the re-sync will automatically include all of the extras. We should probably do the same for both, wdyt?
It's not really clear from uv remove --group gr2 lxml what we should do when we re-sync the project. We can't just remove lxml -- it might still be a requirement, or a requirement of one of your requirements. So we just re-sync with the project's default dependencies, which excludes the group.
Does resynchronization mean deleting all packages?
It turns out that this is the intended algorithm:
The dependency in the group is deleted
The files are deleted from the toml and local
The virtual environment is cleared
And we need to force a separate command to start resynchronization via `uv sync --group gr1 --group gr2?
If I'm wrong, please tell me how the change (deletion, addition, update) in dependency groups was intended.
Re-synchronization means removing any extraneous packages. It's identical to running uv sync at the end of the command (with no additional arguments), which would (correctly) remove the dependencies in those groups, since they're not marked as default groups.
From uv remove --group gr2 lxml alone, it's just not really clear what we should do. We could include all groups, but then we'd often be installing more unrelated packages at the end of uv remove. We could not sync at all -- that's another option.
The behavior for optional dependencies seems to differ here. When using uv remove, the re-sync will automatically include all of the extras. We should probably do the same for both, wdyt?
It is not a problem to re-synchronize by entering the necessary command.
Usually, when deleting a package from a virtual environment, all other packages were NOT deleted. I want to understand why it was done this way, because there may be some complex logic in the CI/CD pipelines and reinstalling all dependencies will slightly, but still affect the speed.
I'm trying to explain the model to you. At the end of uv remove, we perform a uv sync. uv sync will sync the default groups and extras in your project. That could mean removing installed packages. You can pass --no-sync to avoid this. In the future, we could be smarter about what we remove, but it's not trivial.
In short, we want to remove anything was previously required but is no longer required, so we have to diff the resolutions. That may or may not include the package that you specified with uv remove.
In short, we want to remove anything was previously required but is no longer required, so we have to diff the resolutions. That may or may not include the package that you specified with uv remove.
Thank you for your answers
I have determined that for my tasks it is optimal to add a section
[dependency-groups] with two groups main and common.
This way they will be added to the environment via regular uv sync
And for optional dependencies add a section [project.optional-dependencies] with two groups development and test.
They will be added to the project via the flag —extra (uv sync --extra development).
However, there is strange behavior when deleting dependencies again
Example toml
[dependency-groups]
main = [
"six==1.15.0",
]
[project.optional-dependencies]
development = [
"django-debug-toolbar==4.4.2",
"pytest>=8.2.1",
]
[tool.uv]
default-groups = ["main"]
With uv sync - the six package will be installed
With uv add --group main requests==2.31.0 - requests will be installed and will pull in the necessary dependencies
With uv remove --group main requests - all requests dependencies are removed, but all dependencies for the optional development group are installed.
Very strange behavior
Does it make sense to open an issue on this problem?
Thanks for bringing it up. We have some TODOs around this in the codebase but I think we'd just been putting it off until users started hitting it given everything else we had to prioritize.
Reacted by Vladislav, Samuel López Santamaría and Dayal Moirangthem
My expectation running uv remove aiofiles would be that only aiofiles (plus its own dependencies) are removed. However, uv remove aiofiles results in the following uninstalls:
Confirmed as of 0.8.10 - removing main dep removes all optionals except dev ¯_(ツ)_/¯
There is one thing that works: when you try to remove a dependency that is in a group, you get
hint: `cyclopts` is in the `cli` group (try: `uv remove cyclopts --group cli`)
error: The dependency `cyclopts` could not be found in `project.dependencies`
And if you follow the hint, it does what it should - removes just that one.
I was facing the same issue: when I uninstalled one concrete library, uv removed all the dependencies from [dependencies-groups] section too. I found two fixes:
As mentioned before, just do a uv sync --all-groups after removing that dependency (may be a bit tedious, but can be automated with makefile for example)
Put this section in your pyproject.tom file
[tool.uv]
default-groups = [<the names of your groups under dependencies-groups>]
This second option uninstalled only the dependency I wanted, even if the dependency belongs to one of the default groups.
I don't want to put the extra dependencies into the default groups because they are not default dependencies. In my case, I have jupyter in my research group for exploratory purposes, and it shouldn't be in the default group. Every time I remove something, uv will always try to remove jupyter.exe, and because it is being used, the remove command will fail.
Activity
charliermarsh commentedon Nov 11, 2024
Was
"six"removed from thepyproject.toml, or just the virtual environment?VladislavSoren commentedon Nov 11, 2024
I had three packages in my virtual environment: six, pillow and lxml.
With the command uv remove --group gr2 lxml
I wanted to remove only one package
Expected behavior - the package will be removed from all files (tom and lock) and from the virtual environment
In fact - the package is removed from all files (toml and lock) AND all packages are removed from the virtual environment.
In this regard, all dependencies need to be reinstalled.
Is this how it should work?
charliermarsh commentedon Nov 11, 2024
It's not really clear from
uv remove --group gr2 lxmlwhat we should do when we re-sync the project. We can't just removelxml-- it might still be a requirement, or a requirement of one of your requirements. So we just re-sync with the project's default dependencies, which excludes the group.blueraft commentedon Nov 11, 2024
The behavior for optional dependencies seems to differ here. When using
uv remove, the re-sync will automatically include all of the extras. We should probably do the same for both, wdyt?VladislavSoren commentedon Nov 11, 2024
Does resynchronization mean deleting all packages?
It turns out that this is the intended algorithm:
And we need to force a separate command to start resynchronization via `uv sync --group gr1 --group gr2?
If I'm wrong, please tell me how the change (deletion, addition, update) in dependency groups was intended.
charliermarsh commentedon Nov 11, 2024
Re-synchronization means removing any extraneous packages. It's identical to running
uv syncat the end of the command (with no additional arguments), which would (correctly) remove the dependencies in those groups, since they're not marked as default groups.From
uv remove --group gr2 lxmlalone, it's just not really clear what we should do. We could include all groups, but then we'd often be installing more unrelated packages at the end ofuv remove. We could not sync at all -- that's another option.VladislavSoren commentedon Nov 11, 2024
It is not a problem to re-synchronize by entering the necessary command.
Usually, when deleting a package from a virtual environment, all other packages were NOT deleted. I want to understand why it was done this way, because there may be some complex logic in the CI/CD pipelines and reinstalling all dependencies will slightly, but still affect the speed.
charliermarsh commentedon Nov 11, 2024
I'm trying to explain the model to you. At the end of
uv remove, we perform auv sync.uv syncwill sync the default groups and extras in your project. That could mean removing installed packages. You can pass--no-syncto avoid this. In the future, we could be smarter about what we remove, but it's not trivial.charliermarsh commentedon Nov 11, 2024
In short, we want to remove anything was previously required but is no longer required, so we have to diff the resolutions. That may or may not include the package that you specified with
uv remove.VladislavSoren commentedon Nov 13, 2024
Thank you for your answers
I have determined that for my tasks it is optimal to add a section
[dependency-groups] with two groups main and common.
This way they will be added to the environment via regular uv sync
And for optional dependencies add a section [project.optional-dependencies] with two groups development and test.
They will be added to the project via the flag —extra (uv sync --extra development).
VladislavSoren commentedon Nov 13, 2024
However, there is strange behavior when deleting dependencies again
Example toml
With
uv sync- the six package will be installedWith
uv add --group main requests==2.31.0- requests will be installed and will pull in the necessary dependenciesWith
uv remove --group main requests- all requests dependencies are removed, but all dependencies for the optional development group are installed.Very strange behavior
Does it make sense to open an issue on this problem?
charliermarsh commentedon Nov 13, 2024
@VladislavSoren -- It's the same underlying issue. We'll fix it. It's just not a good approach right now.
VladislavSoren commentedon Nov 13, 2024
i've got it. Thank u!
charliermarsh commentedon Nov 13, 2024
Thanks for bringing it up. We have some TODOs around this in the codebase but I think we'd just been putting it off until users started hitting it given everything else we had to prioritize.
inoa-jboliveira commentedon Dec 17, 2024
Hi everyone, I failed to find this issue before writing a new one (sorry!)
But I still would like to understand how sync behaves and if there are docs that explain the existence of a softer sync than the full sync.
And if it is possible for the sync to remember how it was last used so a package that is locked is never removed unless on the real sync command
s-lopez commentedon Dec 24, 2024
To give another example of the same underlying issue in a similar scenario:
Given the following dependencies in
pyproject.toml, which I install withuv sync --all-groups:My expectation running
uv remove aiofileswould be that onlyaiofiles(plus its own dependencies) are removed. However,uv remove aiofilesresults in the following uninstalls:Which is basically everything in the unrelated
sagemakerdependency group, including sub-dependencies.As a workaround, I can circumvent this by running the
--all-groupsagain:liquidcarbon commentedon Mar 22, 2025
I think the default behavior should be
uv remove pkg --no-sync && uv pip uninstall pkg -p .venv/bin/pythonthis is frustrating
what we intend:
gxxeel commentedon Jun 18, 2025
Confirmed, I had the same issue. I fixed it by running an additional
uv sync --all-groupscommand after removing packages from the general group:For example:
When I delete any dependency from the general group, it also deletes every dependency from the tests group:
peacefulotter commentedon Aug 19, 2025
Still having this issue; removing a single package removes all my optional dependencies and I have to run uv sync afterwards.
liquidcarbon commentedon Aug 19, 2025
Confirmed as of 0.8.10 - removing main dep removes all optionals except
dev¯_(ツ)_/¯There is one thing that works: when you try to remove a dependency that is in a group, you get
And if you follow the hint, it does what it should - removes just that one.
dimanu-py commentedon Sep 8, 2025
I was facing the same issue: when I uninstalled one concrete library,
uvremoved all the dependencies from[dependencies-groups]section too. I found two fixes:As mentioned before, just do a
uv sync --all-groupsafter removing that dependency (may be a bit tedious, but can be automated with makefile for example)Put this section in your
pyproject.tomfileThis second option uninstalled only the dependency I wanted, even if the dependency belongs to one of the default groups.
Hope this helps 😄
ziyuang commentedon Apr 23, 2026
Still a problem in 0.11.2.
I don't want to put the extra dependencies into the default groups because they are not default dependencies. In my case, I have
jupyterin myresearchgroup for exploratory purposes, and it shouldn't be in the default group. Every time I remove something,uvwill always try to removejupyter.exe, and because it is being used, the remove command will fail.azhvanko commentedon Jul 16, 2026