poetry lock: Resolve the Lockfile Command Reference
Produce a deterministic lockfile without installing anything.
poetry lock resolves the dependency graph and writes poetry.lock without installing packages. CI commits the lock so every machine resolves to identical versions.
Common flags / usage
- poetry lock -- resolve and write poetry.lock
- --no-update -- refresh the lock to match pyproject.toml without upgrading
- poetry check --lock -- assert the lock matches pyproject.toml
Example
shell
# CI gate: fail the build if the committed lock is stale
- run: poetry check --lockIn CI
Use "poetry check --lock" as a fast gate that fails when poetry.lock does not match pyproject.toml, without resolving everything from scratch. This catches a forgotten re-lock before merge.
Key takeaways
- poetry lock writes a pinned resolution without installing.
- --no-update refreshes the lock without upgrading existing pins.
- poetry check --lock is a cheap staleness gate for CI.
Related guides
poetry install: Install from Lock Command ReferenceReference for poetry install in CI: installing from poetry.lock, the --no-root, --only, and --no-interaction…
poetry add: Add a Dependency Command ReferenceReference for poetry add in CI and dev: adding a dependency to pyproject.toml and the lock, group and dry-run…
poetry run: Run in the Project Env Command ReferenceReference for poetry run in CI: executing a command inside the project virtualenv without activating it, comm…