["python","python-poetry"]
How to update Poetry's lock file without upgrading dependencies?

After adding a [tool.poetry.extras] section to pyproject.toml, Poetry displays the following warning, for example on install: Warning: The lock file is not up to date with the latest changes in pyproject.toml. You may be getting outdated dependencies. Run update to update them. That's fine, but if I run poetry update it upgrades my dependencies, which is not what I want at this time. If I run poetry lock instead, it still upgrades dependencies. Sorry for not providing a reproducible example, it's quite tricky to generate a poetry.lock file with outdated dependencies. My existing one is too large for posting here. Update: Opened sdispater/poetry#1614 for this issue
With poetry v2.0.0 (release date: Jan 5, 2025): poetry lock alone should be enough. As you can see in the v2 documentation: By default, packages that have already been added to the lock file before will not be updated. With poetry v1, the lock action defaults to updating dependencies when recreating the lockfile. There is a specific option for the lock command that prevents this: poetry lock --no-update This makes it possible to remove a dependency from pyproject.toml and update the lock file without upgrading dependencies. Note that this flag is only available since 1.1.2.