Cargo "requires rustc X or newer" - MSRV / rust-version in CI
A dependency declares a minimum supported Rust version (rust-version) higher than the toolchain on your runner. Cargo refuses to build it because your rustc is older than the crate’s MSRV.
What this error means
cargo fails resolving or building with package X requires rustc 1.YY or newer, while the currently active rustc version is 1.ZZ. It appears after a dependency bump raised its MSRV, on a CI runner pinned to an older Rust.
error: package `clap_lex v0.7.4` cannot be built because it requires rustc 1.74
or newer, while the currently active rustc version is 1.70.0
Either upgrade rustc or select compatible dependency versions ...Common causes
A dependency raised its MSRV
A newer release of a dependency bumped its rust-version past the toolchain you build with. Cargo honors that declared minimum and refuses on an older rustc.
CI pinned to an old toolchain
The runner is fixed to an older Rust (an MSRV job or a stale image), so any dependency that moved its floor above it can’t be built.
How to fix it
Update the toolchain to meet the MSRV
Install a Rust version at least as new as the dependency requires.
rustup update stable
rustup default stable
rustc --versionOr pin a dependency version that fits your MSRV
If you must stay on an older Rust, hold the dependency at the last release compatible with it. Cargo can also prefer MSRV-aware resolution.
# pin to the last version supporting your rustc
cargo update -p clap_lex --precise 0.7.0
# or, with a recent cargo, resolve MSRV-aware:
# [resolver] incompatible-rust-versions = "fallback"How to prevent it
- Declare
rust-versionin your manifest to document your real MSRV. - Test your declared MSRV in a dedicated CI job so drift is caught.
- Update the toolchain when dependencies raise their MSRV, or pin compatible versions.