pythonpython-poetry

Warning: The lock file is not up to date with the latest changes in pyproject.toml


When I am using a poetry command with Python 3.7, in my case:

poetry export -f requirements.txt

I am getting the following error:

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.

So far clear, but if I run poetry update it upgrades my dependencies, which is not what I want at this time for my project. If I run poetry lock instead, it still upgrades dependencies.

How can I work around this?


Solution

  • UPDATE V2.0.0 (released date : 4 jan 2025) : The --no-update option does no longer exist (see V2 docs). The same documentation says:

    By default, packages that have already been added to the lock file before will not be updated.

    So now just use: poetry lock or downgrade you poetry version to use the solution below:

    Former answer (before Poetry V2.0.0 release): This is a known issue in Poetry.

    The issue is resolved, use: poetry lock --no-update.

    Old answer:

    There is a current workaround with the following commands:

    poetry add pathlib2
    poetry remove pathlib2
    

    Where pathlib2 is any library you don't already depend on and that has no dependencies on it's own, hence pathlib2.

    Using these commands will rewrite the lockfile hashes and resolve the file conflict without upgrading any of the other packages used in the project.