Skip to content

/errors/poetry/pyproject-toml-changed-significantly

pyproject.toml changed significantly since poetry.lock was last generated. Run `poetry lock`

verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash)updated
tool
Poetry
exit code
1
versions
Poetry 1.x – 2.x
os
any

pyproject.toml changed significantly since poetry.lock was last generated. Run poetry lock to fix the lock file. means the dependency sections of pyproject.toml no longer match the content hash stored in poetry.lock, so Poetry will not install from an out-of-date lock. Run poetry lock (Poetry 2 keeps the already locked versions where possible) and commit the new poetry.lock.

Reproduce it

bash
cat > pyproject.toml <<'EOF'
[project]
name = "demo"
version = "0.1.0"
requires-python = ">=3.10"
dependencies = []

[tool.poetry]
package-mode = false
EOF
# keep the virtual environment inside the project folder
uvx -q poetry@2.5.1 config virtualenvs.in-project true --local
uvx -q poetry@2.5.1 lock -q
# add a dependency without re-locking
sed -i 's/dependencies = \[\]/dependencies = ["six (==1.16.0)"]/' pyproject.toml
uvx -q poetry@2.5.1 check --lock

Output · exit 1

Error: pyproject.toml changed significantly since poetry.lock was last generated. Run `poetry lock` to fix the lock file.

poetry install prints the same sentence and stops before installing anything.

Fix

bash
cat > pyproject.toml <<'EOF'
[project]
name = "demo"
version = "0.1.0"
requires-python = ">=3.10"
dependencies = ["six (==1.16.0)"]

[tool.poetry]
package-mode = false
EOF
uvx -q poetry@2.5.1 config virtualenvs.in-project true --local
uvx -q poetry@2.5.1 lock -q
uvx -q poetry@2.5.1 check --lock

Output

All set!

poetry lock in Poetry 1 and 2

Poetrypoetry lockRefresh everything
1.xRe-resolves and may upgrade every dependency; --no-update keeps locked versionspoetry lock
2.xKeeps locked versions where still valid (the old --no-update behaviour)poetry lock --regenerate

In CI, run poetry check --lock before poetry install: it exits 1 with this message when the lock is stale, which makes the failure obvious in the job log.

Sources