uv: uv add package upgrade doesn't work

Question

I’m sorry for opening this issue here maybe there is a really simple solution. But I cannot find it in documentation. I want to upgrade my package to the latest version and at the same time updating pyproject.toml file.

Image

Image

But it doesn’t update to the latest version. uv pip install haystack-ai --upgrade command upgrades but it doesn’t update toml file.

Platform

Linux 6.11.0-17-generic 24.04.2-Ubuntu SMP PREEMPT_DYNAMIC x86_64 GNU/Linux

Version

0.5.31

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 17 (7 by maintainers)

Most upvoted comments

I think you’re looking for uv sync --upgrade or uv sync --upgrade-package haystack-ai. You might just be missing the uv sync command here?

uv sync will only update the lockfile (and venv); I believe OP wants the version boundaries in pyproject.toml bumped, too.

My solution is

uv pip install haystack-ai --upgrade
uv pip freeze > requirements.txt
uv add -r requirements.txt
uv export --format requirements-txt > requirements.txt

Related #6794

I have been looking for uv’s equivalent of poetry up (plugin) and this issue seems to be related.

Yes, thank you @kshpytsya. I didn’t know poetry had the same deficiency / lack.
@charliermarsh I checked that repo and there are more 300 stars. I’m sure many uv users would like this feature to be in uv too. I use uv in --no-package --app mode so I always need to upgrade some specific packages without touching the others to not create more conflicts.

I have been looking for uv’s equivalent of poetry up (plugin) and this issue seems to be related.

I don’t think uv add -U modifies the version bounds in the pyproject.toml, but it should upgrade the version in the lockfile. Is it necessary for you upgrade the lower-bound in the pyproject.toml? If so, why?

@charliermarsh But it doesn’t upgrade the package anyway. So if I wanted to upgrade a package and lock this information do I need to use two commands?

uv pip install haystack-ai --upgrade
uv lock --upgrade-package haystack-ai

Even when I do it doesn’t work. It upgrades to 2.10 but doesn’t make any change neither on lock or toml.

+sglbl@SGLBLPC11:~/codes/example$ uv lock --upgrade-package haystack-ai
Resolved 39 packages in 194ms
+sglbl@SGLBLPC11:~/codes/example$ cat uv.lock | grep haystack-ai
    { name = "haystack-ai" },
requires-dist = [{ name = "haystack-ai", specifier = "==2.4.0" }]
name = "haystack-ai"
    { name = "haystack-ai" },
+sglbl@SGLBLPC11:~/codes/example$ uv add -U haystack-ai
Resolved 39 packages in 355ms
Audited 37 packages in 0.01ms
+sglbl@SGLBLPC11:~/codes/example$ cat uv.lock | grep haystack-ai
    { name = "haystack-ai" },
requires-dist = [{ name = "haystack-ai", specifier = "==2.4.0" }]
name = "haystack-ai"
    { name = "haystack-ai" },
+sglbl@SGLBLPC11:~/codes/example$ uv add haystack-ai --refresh
Resolved 39 packages in 0.79ms
Audited 37 packages in 0.01ms
+sglbl@SGLBLPC11:~/codes/example$ cat uv.lock | grep haystack-ai
    { name = "haystack-ai" },
requires-dist = [{ name = "haystack-ai", specifier = "==2.4.0" }]
name = "haystack-ai"
    { name = "haystack-ai" },
+sglbl@SGLBLPC11:~/codes/example$ uv pip install haystack-ai --upgrade
Resolved 52 packages in 712ms
Prepared 18 packages in 2.36s
Uninstalled 3 packages in 21ms
Installed 18 packages in 48ms
 + aiohappyeyeballs==2.4.6
 + aiohttp==3.11.12
 + aiosignal==1.3.2
 + async-timeout==5.0.1
 + attrs==25.1.0
 + frozenlist==1.5.0
- haystack-ai==2.4.0
+ haystack-ai==2.10.0
 + jsonref==1.1.0
 + jsonschema==4.23.0
 + jsonschema-specifications==2024.10.1
 + multidict==6.1.0
 - numpy==1.26.4
 + numpy==2.2.3
 + openapi-llm==0.4.1
 - posthog==3.13.0
 + posthog==3.11.0
 + propcache==0.2.1
 + referencing==0.36.2
 + rpds-py==0.22.3
 + yarl==1.18.3
+sglbl@SGLBLPC11:~/codes/example$ cat uv.lock | grep haystack-ai
    { name = "haystack-ai" },
requires-dist = [{ name = "haystack-ai", specifier = "==2.4.0" }]
name = "haystack-ai"
    { name = "haystack-ai" },
+sglbl@SGLBLPC11:~/codes/example$ uv add -U haystack-ai
Resolved 39 packages in 309ms
Prepared 3 packages in 0.77ms
Uninstalled 3 packages in 22ms
Installed 3 packages in 43ms
 - haystack-ai==2.10.0
 + haystack-ai==2.4.0
 - numpy==2.2.3
 + numpy==1.26.4
 - posthog==3.11.0
 + posthog==3.13.0
+sglbl@SGLBLPC11:~/codes/example$ uv pip install haystack-ai --upgrade
Resolved 52 packages in 339ms
Prepared 3 packages in 0.55ms
Uninstalled 3 packages in 18ms
Installed 3 packages in 37ms
- haystack-ai==2.4.0
+ haystack-ai==2.10.0
 - numpy==1.26.4
 + numpy==2.2.3
 - posthog==3.13.0
 + posthog==3.11.0
+sglbl@SGLBLPC11:~/codes/example$ uv lock --upgrade-package haystack-ai
Resolved 39 packages in 134ms
+sglbl@SGLBLPC11:~/codes/example$ cat uv.lock | grep haystack-ai
    { name = "haystack-ai" },
@@requires-dist = [{ name = "haystack-ai", specifier = "==2.4.0" }]@@  # there is no change
name = "haystack-ai"
    { name = "haystack-ai" },