Skip to content
Latchkey

rustup: Set the Default Toolchain in CI

rustup default <toolchain> sets the toolchain cargo uses everywhere; a rust-toolchain.toml or rustup override pins it per directory instead.

Fresh CI installs of rustup may have no default toolchain, so cargo fails immediately. Setting a default, or letting rust-toolchain.toml pin one, is the fix.

What it does

rustup resolves which toolchain to use in priority order: an explicit +toolchain argument, a rust-toolchain.toml/rust-toolchain file, a directory override set with rustup override set, then the global default from rustup default. With none set, cargo cannot pick a toolchain.

Common usage

bash
rustup default stable
# or pin per-directory
rustup override set 1.78.0
# or commit rust-toolchain.toml:
#   [toolchain]
#   channel = "1.78.0"
#   components = ["clippy", "rustfmt"]
cargo build

Options

Command / flagWhat it does
rustup default <ch>Set the global default toolchain
rustup override set <ch>Pin a toolchain for the current directory
rustup override listShow directory overrides
rust-toolchain.tomlRepo-committed pin (channel/components/targets)
rustup showShow the active toolchain and how it was chosen
RUSTUP_TOOLCHAINEnv var that forces a toolchain

In CI

Prefer committing rust-toolchain.toml so the toolchain is pinned in version control and auto-installed on first cargo invocation; you then need no rustup commands at all. If you install rustup manually with --default-toolchain none, remember to set a default before calling cargo.

Common errors in CI

"error: no default toolchain configured" means rustup is installed but nothing is selected; run rustup default stable or add rust-toolchain.toml. "error: override toolchain 'X' is not installed" means an override file pins a version absent on the runner; install it. "info: syncing channel updates" hanging usually points at a slow/blocked static.rust-lang.org.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →