Rust "no override and no default toolchain set" in CI
rustup is installed but has no toolchain selected - no per-directory override and no global default. With nothing to dispatch to, cargo and rustc shims refuse to run.
What this error means
Any cargo or rustc invocation fails with error: no override and no default toolchain set. It happens after a minimal rustup install (e.g. --no-default-toolchain) where no toolchain was ever made the default.
error: rustup could not choose a version of cargo to run, because one wasn't
specified explicitly, and no default is configured.
help: run 'rustup default stable' to download the latest stable release of Rust
and set it as your default toolchain.Common causes
rustup installed without a default toolchain
Installing with --no-default-toolchain (or a stripped image) leaves rustup with the shims but no toolchain selected, so it can’t choose what to run.
No directory override either
Without a rust-toolchain.toml, a rustup override, or a global default, rustup has no signal for which toolchain a command should use.
How to fix it
Set a default toolchain
rustup default stable
rustc --version # confirms a toolchain is now selectedOr pin one via the setup action / toolchain file
A setup action or a committed rust-toolchain.toml selects the toolchain without a manual default.
# rust-toolchain.toml at repo root
[toolchain]
channel = "1.85.0"How to prevent it
- Run
rustup default stable(or commit arust-toolchain.toml) early in CI. - Use a setup action that installs and selects a toolchain.
- Avoid
--no-default-toolchainunless you immediately pin one.