rust-lang/cargo · error · anyhow::Error
`resolver` setting `{}` is not valid, valid options are "1",
Error message
`resolver` setting `{}` is not valid, valid options are "1", "2" or "3" What it means
`ResolveBehavior::from_manifest` parses the `resolver` key under `[package]` (or workspace) in `Cargo.toml`. Only the literal strings `"1"`, `"2"`, `"3"` are accepted; anything else (e.g. `"true"`, `"v2"`, `"4"`, or a number) bails with this message listing the valid options.
Source
Thrown at src/resolver/types.rs:124
/// Resolver behavior, used to opt-in to new behavior that is
/// backwards-incompatible via the `resolver` field in the manifest.
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
pub enum ResolveBehavior {
/// V1 is the original resolver behavior.
V1,
/// V2 adds the new feature resolver.
V2,
/// V3 changes version preferences
V3,
}
impl ResolveBehavior {
pub fn from_manifest(resolver: &str) -> CargoResult<ResolveBehavior> {
match resolver {
"1" => Ok(ResolveBehavior::V1),
"2" => Ok(ResolveBehavior::V2),
"3" => Ok(ResolveBehavior::V3),
s => anyhow::bail!(
"`resolver` setting `{}` is not valid, valid options are \"1\", \"2\" or \"3\"",
s
),
}
}
pub fn to_manifest(&self) -> String {
match self {
ResolveBehavior::V1 => "1",
ResolveBehavior::V2 => "2",
ResolveBehavior::V3 => "3",
}
.to_owned()
}
}
/// Options for how the resolve should work.
#[derive(Clone, Debug, Eq, PartialEq, Hash)]View on GitHub (pinned to 0e07a15537)
Solutions
- Set `resolver = "2"` (or `"1"`/`"3"`) as a quoted string in `[package]` or `[workspace]`.
- Upgrade Cargo if you intended a newer resolver value not yet supported by your toolchain.
- Remove the `resolver` key entirely to use the default for your edition (edition 2021+ defaults to V2).
Example fix
# before [package] resolver = "v2" # after [package] resolver = "2"
Defensive patterns
Strategy: validation
Validate before calling
# Validate the resolver key is one of the allowed strings: tomlq -r '.package.resolver // .workspace.resolver' Cargo.toml \ | grep -qE '^[123]$' || echo 'resolver must be "1", "2", or "3"'
Prevention
- Only ever write `resolver = "2"` (or omit it on edition 2021+).
- Keep Cargo.toml linters in CI to catch typos.
- Upgrade Cargo if you need a newer resolver value.
When it happens
Trigger: Setting `resolver = "v2"`, `resolver = 2` (unquoted integer is a TOML error separately), `resolver = "4"`, or any non-`"1"/"2"/"3"` string in `[package]`/`[workspace]`. The `match resolver { s => bail!(...) }` catch-all arm fires.
Common situations: Typos in `Cargo.toml`; copying a config snippet from outdated docs; using a future resolver value on an older Cargo; mixing up `resolver` (behavior selector) with edition.
Related errors
- could not compile due to {error_count} previous target resol
- {manifest_key_name} `{}` does not appear to exist{}.
- multiple registries are configured with the same index url '
- '{}' is not a valid artifact specifier
- Cannot specify both 'bin' and 'bin:<name>' binary artifacts,
AI-assisted analysis of rust-lang/cargo@0e07a15537 (2026-08-06).
Data as JSON: /data/errors/9f69a66f82ea2e2d.json.
Report an issue: GitHub.