{"id":"9f69a66f82ea2e2d","repo":"rust-lang/cargo","slug":"resolver-setting-is-not-valid-valid-option","errorCode":null,"errorMessage":"`resolver` setting `{}` is not valid, valid options are \"1\", \"2\" or \"3\"","messagePattern":"`resolver` setting `(.+?)` is not valid, valid options are \"1\", \"2\" or \"3\"","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/resolver/types.rs","lineNumber":124,"sourceCode":"/// Resolver behavior, used to opt-in to new behavior that is\n/// backwards-incompatible via the `resolver` field in the manifest.\n#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]\npub enum ResolveBehavior {\n    /// V1 is the original resolver behavior.\n    V1,\n    /// V2 adds the new feature resolver.\n    V2,\n    /// V3 changes version preferences\n    V3,\n}\n\nimpl ResolveBehavior {\n    pub fn from_manifest(resolver: &str) -> CargoResult<ResolveBehavior> {\n        match resolver {\n            \"1\" => Ok(ResolveBehavior::V1),\n            \"2\" => Ok(ResolveBehavior::V2),\n            \"3\" => Ok(ResolveBehavior::V3),\n            s => anyhow::bail!(\n                \"`resolver` setting `{}` is not valid, valid options are \\\"1\\\", \\\"2\\\" or \\\"3\\\"\",\n                s\n            ),\n        }\n    }\n\n    pub fn to_manifest(&self) -> String {\n        match self {\n            ResolveBehavior::V1 => \"1\",\n            ResolveBehavior::V2 => \"2\",\n            ResolveBehavior::V3 => \"3\",\n        }\n        .to_owned()\n    }\n}\n\n/// Options for how the resolve should work.\n#[derive(Clone, Debug, Eq, PartialEq, Hash)]","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/rust-lang/cargo/blob/0e07a155371a6ce88ae53a2c00df940280c09a67/src/resolver/types.rs#L106-L142","documentation":"`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.","triggerScenarios":"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.","commonSituations":"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.","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)."],"exampleFix":"# before\n[package]\nresolver = \"v2\"\n# after\n[package]\nresolver = \"2\"","handlingStrategy":"validation","validationCode":"# Validate the resolver key is one of the allowed strings:\ntomlq -r '.package.resolver // .workspace.resolver' Cargo.toml \\\n  | grep -qE '^[123]$' || echo 'resolver must be \"1\", \"2\", or \"3\"'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["manifest","config","resolver","validation"],"analyzedSha":"0e07a155371a6ce88ae53a2c00df940280c09a67","analyzedAt":"2026-08-06T01:46:58.334Z","schemaVersion":2}