Safeguard
Developer Tools•

Why is poetry update a no-op for my vulnerable package?

Poetry update stays inside your pyproject constraints and never edits them. When the fix is outside the range, use poetry add to change the constraint.

Safeguard Security Team
4 min read

Poetry update stays inside the version constraints in pyproject.toml and only rewrites poetry.lock. If the fixed release lies outside that constraint, naming the package does nothing. Change the constraint with poetry add, then let Poetry resolve and write the lock file.

What the documentation says

The Poetry documentation describes poetry update as resolving all dependencies, writing exact versions into poetry.lock and installing them. It then states a note that matters here: the update command does not modify pyproject.toml. It updates only the lock file with the latest compatible versions based on the constraints already defined. To change constraints, use the add command.

You can update a few packages by listing them. The docs warn that this will not update dependencies outside the constraints in pyproject.toml. In other words, updating a package whose constraint is tilde 2.3 or exactly 2.3 is a no-op when 2.4 is available. For it to move, the constraint must change, for example to a caret range, and the add command is how to do that.

Decision table

SituationCommand ideaEdits pyproject.toml?
Fixed version inside your constraintpoetry update with the package nameNo
Fixed version outside your constraintpoetry add with a new constraintYes
Transitive package, parent allows fixpoetry update with the package nameNo
Transitive package, parent caps itUpgrade the parentMaybe

Steps for a security fix

  1. Read the advisory for the first fixed version.
  2. Check your constraint for the package in pyproject.toml.
  3. If the fix fits, run poetry update with that one package name. If not, run poetry add with a constraint that admits the fix.
  4. Read the poetry.lock diff. Only the expected packages should change.
  5. Install from the lock file in a clean environment and run tests.
  6. Commit pyproject.toml and poetry.lock together.
poetry update somepackage
poetry add "somepackage>=2.0.1,<3"

Locking versus updating

Poetry also separates installing from updating. The docs say poetry install uses the lock file when present, and for exact reproducible installs they recommend poetry sync, which also removes packages that are not in the lock file. Use poetry update when you want the latest versions within the constraints and a refreshed lock file. A related command, poetry lock, rewrites the lock file, and the docs say the update with the lock option and poetry lock with the regenerate option normally produce the same result.

For CI, install from the lock so the tested versions are the shipped ones. If you are unsure whether to commit the lock file in a library, see the guide on whether to commit poetry.lock for applications versus libraries.

Try it yourself

Click through it at your own pace, or open it full screen. Follow one finding to its fixed version and check whether your constraint allows it.

Where Safeguard fits

Safeguard scans dependencies, runs reachability analysis to show which findings your code can actually reach, and can open fix pull requests through autonomous remediation. That last feature is off by default and every category starts on Manual, so a person approves each change. You can try a free scan on a repository first.

Quick check

Does poetry update change pyproject.toml?

No. It only updates poetry.lock within existing constraints. Use poetry add to change a constraint.

What does poetry sync do that install does not?

It also removes packages that are not in the lock file, giving a cleaner reproducible environment.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.