Rust "the cargo binary ... does not exist" for a Toolchain in CI
By Daniel Zoghalchali·Latchkey
rustup selected a toolchain whose cargo binary is missing. The toolchain install is partial or corrupt -- often from an interrupted download or a half-restored cache -- so the active toolchain has no usable cargo.
What this error means
A cargo invocation fails with the 'cargo' binary, normally found at <path>, does not exist. rustup thinks the toolchain is installed, but the binary is absent, usually after a broken install or truncated cache restore.
rustup
error: the 'cargo' binary, normally found at
'/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo',
does not exist
Diagnose it: toolchain, features, cache
Terminal
rustc --version --verbose && cargo --version
cat rust-toolchain.toml 2>/dev/null
cargo tree -e features | head -30
cargo clean && cargo build --locked
Common causes
Partial or corrupt toolchain install
An interrupted rustup install (network drop, cancelled job) left the toolchain directory present but missing the cargo binary.
Truncated or stale toolchain cache
A restored ~/.rustup cache that was saved mid-install -- or partially restored -- contains a toolchain metadata entry without the actual binaries.
How to fix it
Reinstall the toolchain
Force a clean reinstall so the binaries are restored.
Cache ~/.rustup only after the toolchain install succeeds.
Reinstall the toolchain if a cargo binary goes missing.
Avoid saving caches from cancelled or failed setup steps.
Frequently asked questions
What causes Rust "the cargo binary ... does not exist" for a toolchain in CI?
There are 2 common causes: partial or corrupt toolchain install and truncated or stale toolchain cache. An interrupted rustup install (network drop, cancelled job) left the toolchain directory present but missing the cargo binary.
How do I fix Rust "the cargo binary ... does not exist" for a toolchain in CI?
There are 2 fixes depending on which cause you have: reinstall the toolchain and clear a corrupt cache and re-fetch. Work through them in order, since the first is the most common.
What does Rust "the cargo binary ... does not exist" for a toolchain in CI actually mean?
A cargo invocation fails with the 'cargo' binary, normally found at <path>, does not exist.
How do I stop Rust "the cargo binary ... does not exist" for a toolchain in CI happening again?
Cache ~/.rustup only after the toolchain install succeeds. The prevention section lists 3 changes that keep it from recurring.