Skip to content

uv sync --script only syncs when there are packages to add to env #12145

Closed
@manzt

Description

@manzt

Summary

I'm not entirely sure I understand the behavior, but it seems like there's a subtle bug where uv sync --script only syncs the environment when there are new dependencies to add. Specifically, removing dependencies and then syncing appears to be a no-op.

uv init --script blah.py
uv add --script blah.py polars
uv sync --script blah.py
# Creating script environment at: /Users/manzt/.cache/uv/environments-v2/blah-7cdfc916d13f4258
# Resolved 1 package in 12ms
# Installed 1 package in 6ms
#  + polars==1.24.0
uv remove --script blah.py polars
uv sync --script blah.py
# Using script environment at: /Users/manzt/.cache/uv/environments-v2/blah-7cdfc916d13f4258
#
uv add --script blah.py attrs
uv sync --script blah.py
# Using script environment at: /Users/manzt/.cache/uv/environments-v2/blah-7cdfc916d13f4258
# Resolved 1 package in 51ms
# Uninstalled 1 package in 15ms
# Installed 1 package in 3ms
#  + attrs==25.2.0
#  - polars==1.24.0

In the script above, I would expect - polars==1.24.0 to appear after uv remove --script blah.py polars. I can confirm that polars is still in the environment until after the last uv sync.

Platform

Darwin 23.6.0 arm64

Version

uv 0.6.6 (c1a0bb8 2025-03-12)

Python version

Python 3.13

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions