How to update Poetry's lock file without upgrading dependencies?

Claudio picture Claudio · Nov 20, 2019 · Viewed 8.2k times · Source

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

Answer

slhck picture slhck · Nov 5, 2020

There is now an option since 1.1.2 (or earlier?):

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 the behavior will be changed in v2.0.