Your Cargo package sets `rust-version = "1.85"` on edition 2024; why does Cargo lock an older dependency release than resolver "2" would, and how do you override it?
answer
- resolver version follows the edition
- compares each release's rust-version
- a preference, not a hard filter
- config table, env var, CLI flag
basics
~20 sEdition 2024 implies resolver "3", the MSRV-aware resolver stabilised in Cargo 1.84: it prefers dependency releases whose rust-version is at most yours, falling back to newer ones only when none fit. Override with resolver.incompatible-rust-versions = "allow", --ignore-rust-version or cargo update --precise.
solid answer
~40 sResolver `"3"`, stabilised in Cargo 1.84 and the default for edition 2024 packages, changes one default: `resolver.incompatible-rust-versions` goes from `allow` to `fallback`. With `fallback`, Cargo prefers releases whose declared `rust-version` is at most your package's `rust-version` (or your toolchain's version if you set none), so with 1.85 it locks heapless 0.8.0 and prints `Adding heapless v0.8.0 (available: v0.9.3, requires Rust 1.87)`. It is a preference, not an error: if no release in the range fits, it picks a newer one anyway. To get the newest releases, set the config key to `allow` (also via `CARGO_RESOLVER_INCOMPATIBLE_RUST_VERSIONS=allow`), pass `--ignore-rust-version`, raise the requirement, or name the version with `cargo update --precise`. Resolver `"2"` ignores `rust-version` when choosing.
code
toml · 8 lines[package]
name = "ring-buffer"
version = "0.1.0"
edition = "2024"
rust-version = "1.85"
[dependencies]
heapless = ">=0.8, <0.10"go deeper
Know that Cargo has resolver versions, that the edition picks a default, and that rust-version declares the oldest Rust a package supports.
Explain how edition 2024 selects resolver 3 and read the Locking line that names the Rust version used for selection.
Explain fallback as a preference with an escape hatch, show each override, and say why a workspace with mixed rust-versions may get surprising picks.
Decide how resolver 3 fits the team's MSRV promise: the default lockfile, plus a separate job that tests the newest releases with allow.
## What the resolver version controls The **resolver version** is a workspace-wide setting that changes how Cargo resolves the graph. It comes from `package.resolver` (or `workspace.resolver` in a virtual workspace) and is read **only from the top-level manifest**; a dependency's setting is ignored. When unset, the edition decides: | Setting | Default for | What it changes | |---|---|---| | `"1"` | no edition key, 2015, 2018 | Original behaviour | | `"2"` | edition 2021 | Feature unification: keeps build, dev and target-specific dependency features apart | | `"3"` | edition 2024, needs Rust 1.84+ | Default for `resolver.incompatible-rust-versions` becomes `fallback` | Resolver 2's feature changes belong to the material on features. Resolver 3 keeps them and adds **Rust-version awareness** to version selection. It was stabilised in **Cargo 1.84** together with the `[resolver]` table in Cargo's configuration, and the 2024 edition (Rust 1.85) made it the default for edition 2024 packages. A virtual workspace manifest has no edition, so anything but `"1"` needs `workspace.resolver` written out; Cargo 1.99 warns when a virtual workspace falls back to `"1"` while members are on edition 2024. ## How fallback picks versions Every published release can declare the oldest Rust it supports in its own `rust-version`. With `fallback`: 1. Cargo compares each candidate release's `rust-version` with **your** `rust-version`; if your package sets none, it compares with the toolchain running Cargo. 2. Among releases that satisfy the requirement, it **prefers** those whose `rust-version` is at most yours, taking the highest of them. 3. If none in the range qualify, it **does not error**; it picks a release anyway, potentially one your MSRV cannot build. The progress line tells you which mode ran: `Locking 4 packages to highest Rust 1.85 compatible versions` under fallback, `Locking 4 packages to highest compatible versions` under `allow`. When fallback skips a newer release, Cargo prints what it passed over, for example `Adding heapless v0.8.0 (available: v0.9.3, requires Rust 1.87)`; when it had to take an incompatible one, `Adding heapless v0.9.3 (requires Rust 1.87)`. In a workspace whose members declare different `rust-version`s, the resolver cannot always tell which member a shared dependency serves, so the Cargo book warns it may pick lower, or higher, versions than one member alone would get. ## A worked run With the manifest shown in the example (edition 2024, `rust-version = "1.85"`, `heapless = ">=0.8, <0.10"`) and Cargo 1.99.1: 1. Default settings lock **0.8.0**, the newest release declaring Rust 1.85 or older, and name the skipped 0.9.3. 2. `resolver.incompatible-rust-versions = "allow"` locks **0.9.3**. 3. `--ignore-rust-version` locks **0.9.3**. 4. `resolver = "2"` in the manifest locks **0.9.3**. 5. Narrowing the requirement to `"0.9"` leaves no compatible release, so fallback takes **0.9.3** and says it requires Rust 1.87. ## Overriding it - **Config:** `resolver.incompatible-rust-versions = "allow"` in `.cargo/config.toml`, or `--config 'resolver.incompatible-rust-versions="allow"'` for one command. - **Environment:** `CARGO_RESOLVER_INCOMPATIBLE_RUST_VERSIONS=allow`, which the Cargo book's CI guide uses in a job that tests the newest dependencies. - **Command line:** `--ignore-rust-version` ignores `rust-version` for that run. - **Per dependency:** raise the requirement above every compatible release, or run `cargo update -p NAME --precise VERSION`. - **Go back:** set `resolver = "2"`, which restores the `allow` default. The `[resolver]` table is a local development setting: the config reference notes it does not apply to `cargo install`. ## Why it exists, and its limits Before 1.84 a crate with `rust-version = "1.70"` could run `cargo update` on a current toolchain and lock releases needing 1.80, and only the MSRV CI job would notice. Resolver 3 keeps the lockfile buildable on the declared MSRV by default. - **It changes choices, not builds.** Building a package whose own `rust-version` is newer than the toolchain is still an error, and resolver 3 does not change that check. - **It affects your lockfile only.** Dependents resolve with their own resolver and their own `rust-version`. - **It trusts declarations.** A release that omits `rust-version` or understates it is treated as compatible. - **Edition 2024 requires `rust-version` of at least 1.85**; Cargo refuses a manifest with a lower one. Choosing the MSRV itself is a policy question covered with Rust's release train; this question is about what Cargo does with it.
- What does resolver 3 do when no release in the range supports your rust-version?It still resolves. Fallback is a preference: if nothing in the range declares a compatible `rust-version`, Cargo picks a release anyway and notes it, as in `Adding heapless v0.9.3 (requires Rust 1.87)`. The lockfile then needs a newer Rust than your MSRV, which your MSRV CI job has to catch.
- Your repository root is a virtual manifest with edition 2024 members. Which resolver runs?A virtual manifest has no edition, so it uses `"1"` unless `workspace.resolver` is set; Cargo 1.99 warns that the virtual workspace is defaulting to `resolver = "1"` despite edition 2024 members. Set `workspace.resolver = "3"` in the root to get the MSRV-aware behaviour.
- Resolver 3 refuses dependencies newer than the MSRV
- Each crate's resolver setting applies to its own dependencies
- Resolver 3 replaces resolver 2's feature handling
- Resolver 3 is on in every edition since Cargo 1.84
- Fallback picks the oldest release that supports my MSRV
Assumes Cargo 1.99; resolver "3" and the [resolver] config table were stabilised in Cargo 1.84, and the 2024 edition (Rust 1.85) made it the default.