What a yank changes#
A yank removes a version from the registry's index of versions that Cargo may choose. It deletes nothing. The cargo yank documentation says the version "will still be available for download", and that Cargo "will not use a yanked version for any new project or checkout without a pre-existing lockfile".
That last clause explains why the build still works. A lockfile that already names the yanked version keeps resolving to it, so cargo build downloads and compiles it as before. Only new resolutions avoid it. Authors usually yank a release that broke something, such as a wrong minimum Rust version or a soundness bug, and publish a fixed patch release beside it.
cargo deny reads the same index. Its advisories check looks up every crate in Cargo.lock and reports any version the registry marks as yanked. How loudly it reports depends on one field. The advisories configuration reference lists three levels for yanked: deny emits an error and fails the check, warn (the default) prints a warning, and allow prints a note. A project that sets yanked = "deny" therefore fails CI on every branch at the moment the author yanks, including branches whose last commit is weeks old.
This is a different signal from a RustSec advisory. An advisory says something about the code. A yank only says the author withdrew the release, often without saying why. The guide on unmaintained RustSec advisories covers the advisory side.
The lab#
The lab needs Docker and network access to crates.io, and runs in about a minute. It uses sha2 0.11.2, which crates.io has yanked, and the prebuilt cargo-deny 0.22.2 binary from the project's releases.
docker run --rm -it --name cargo-deny-yanked-lab rust:1 bash
curl -sSL https://github.com/EmbarkStudios/cargo-deny/releases/download/0.22.2/cargo-deny-0.22.2-x86_64-unknown-linux-musl.tar.gz \
| tar xz --strip-components=1 -C /usr/local/cargo/bin cargo-deny-0.22.2-x86_64-unknown-linux-musl/cargo-deny
cargo new -q hasher && cd hasher
cargo add -q sha2@0.11.1
printf '[advisories]\nyanked = "deny"\n' > deny.toml
A fresh resolution picks 0.11.3, because Cargo skips the yanked 0.11.2. To reproduce a lockfile written before the yank, move it back by hand. Cargo 1.100 allows that and warns:
$ cargo update -p sha2 --precise 0.11.2
warning: selected package `sha2@0.11.2` was yanked by the author
= help: if possible, try a compatible non-yanked version
Downgrading sha2 v0.11.3 -> v0.11.2
cargo build still succeeds with this lockfile. cargo deny does not:
$ cargo deny check advisories
error[yanked]: detected yanked crate (try `cargo update -p sha2`)
┌─ /tmp/hasher/Cargo.lock:10:1
│
10 │ sha2 0.11.2 registry+https://github.com/rust-lang/crates.io-index
│ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ yanked version
│
├ sha2 v0.11.2
└── hasher v0.1.0
advisories FAILED
The exit status is 1. Without the deny.toml line, the same run prints warning[yanked] and exits 0.
The fix: one precise update#
The hint suggests cargo update -p sha2. That works, but it may also move the crate further than you need. Name the yanked version and the target instead:
$ cargo update -p sha2@0.11.2 --precise 0.11.3
Updating sha2 v0.11.2 -> v0.11.3
$ cargo deny check advisories
advisories ok
The NAME@VERSION form matters in a large workspace. When the graph holds two incompatible lines of the same crate, say 0.10 and 0.11, -p sha2 alone stops with error: specification sha2 is ambiguous, while -p sha2@0.11.2 selects only the yanked copy. The cargo update reference documents --precise. Read the lockfile diff before committing it: it should change the one package entry and nothing else.
Pick the target from the crate's registry listing. The nearest later patch release is usually the replacement the author published. Before you open the pull request, find out who pulls the crate in:
$ cargo tree -i sha2@0.11.2
sha2 v0.11.2
└── hasher v0.1.0 (/tmp/hasher)
If a dependency pins the yanked version exactly, with =0.11.2, --precise stops with failed to select a version for the requirement sha2 = "=0.11.2", and the fix is a new release of that dependency.
When there is no replacement yet#
Sometimes the author yanks a release before the fix is out. Then CI is red with nothing to move to. cargo deny accepts a yanked crate in the ignore list with a reason:
[advisories]
yanked = "deny"
ignore = [{ crate = "sha2@0.11.2", reason = "yanked; waiting for 0.11.3" }]
With that entry the lab's check prints advisories ok. Remove the entry when the replacement ships, or the exception outlives its reason. The same reference documents an expiry field for advisory ignores that makes the exception lapse on a date.
Whether to deny yanked versions at all is a policy choice. deny makes the whole team notice within hours of the yank, at the cost of red CI on unrelated changes. warn keeps CI green and relies on someone reading warnings. If you choose deny, expect the failure to arrive on a day nobody touched dependencies, and keep the fix small enough to merge ahead of everything else in the queue. Automated dependency pull requests, covered in reviewing dependency bot pull requests, often carry the same bump a day later.
In production#
In the case behind this guide, crates.io yanked sha2 0.11.2 while a service's lockfile pinned it through an AWS signing crate. cargo deny ran with yanked = "deny" in the fast check of every pull request and every merge group, so every one of them failed with error[yanked]: detected yanked crate (try cargo update -p sha2). The fix was the single command cargo update -p sha2@0.11.2 --precise 0.11.3. It changed only the sha2 entry and the references to it from 42 dependent packages, and left the older 0.10.9 copy and a second lockfile untouched.
Where this came from#
Proofline found this in its own control plane's CI and shipped the fix in its production release of 30 November 2026. The error[yanked] text and the one-command fix above are that case's. Proofline reviews GitHub pull requests; new organizations get one calendar month of hosted code review without a cloud connection. Start a free GitHub review · Eligibility and fair-use terms
Questions#
Does a yanked crate break my build?
No. A lockfile that already names the yanked version keeps building, because the registry still serves the file. Only new resolutions skip it, and only tools that read the yank flag, such as cargo deny, fail on it.
Should I run cargo update without arguments to clear the error?
Avoid it. A bare cargo update moves every dependency to its newest compatible version and turns a one-line fix into a large lockfile change. Use cargo update -p NAME@YANKED --precise NEXT.
Can I stop cargo deny from checking yanked crates?
Yes. Set yanked = "warn" or "allow", or disable-yank-checking = true, in the [advisories] section. An ignore entry for the one crate version is narrower and leaves the check on for the rest of the graph.