{"record":{"id":"9f34c55a43dee4b0","repo":"rust-lang/cargo","slug":"metadata-version-not-supported-only-is-curr","errorCode":null,"errorMessage":"metadata version {} not supported, only {} is currently supported","messagePattern":"metadata version (.+?) not supported, only (.+?) is currently supported","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/ops/cargo_metadata.rs","lineNumber":29,"sourceCode":"use serde::Serialize;\nuse std::collections::BTreeMap;\nuse std::path::PathBuf;\n\nconst VERSION: u32 = 1;\n\npub struct OutputMetadataOptions {\n    pub cli_features: CliFeatures,\n    pub no_deps: bool,\n    pub version: u32,\n    pub filter_platforms: Vec<String>,\n}\n\n/// Loads the manifest, resolves the dependencies of the package to the concrete\n/// used versions - considering overrides - and writes all dependencies in a JSON\n/// format to stdout.\npub fn output_metadata(ws: &Workspace<'_>, opt: &OutputMetadataOptions) -> CargoResult<ExportInfo> {\n    if opt.version != VERSION {\n        anyhow::bail!(\n            \"metadata version {} not supported, only {} is currently supported\",\n            opt.version,\n            VERSION\n        );\n    }\n    let (packages, resolve) = if opt.no_deps {\n        let packages = ws\n            .members()\n            .map(|pkg| pkg.serialized(ws.gctx().cli_unstable(), ws.unstable_features()))\n            .collect();\n        (packages, None)\n    } else {\n        let (packages, resolve) = build_resolve_graph(ws, opt)?;\n        (packages, Some(resolve))\n    };\n\n    Ok(ExportInfo {\n        packages,","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/rust-lang/cargo/blob/eb98b54bc9f3c74519f43d066cb3fd02ebc88df0/src/ops/cargo_metadata.rs#L11-L47","documentation":"`cargo metadata --format-version N` accepts only `VERSION` (currently `1`). Any other integer — `2`, `3`, `0`, or omitted — is rejected outright because cargo only guarantees stability of the v1 schema. The version is pinned to a module-level constant to keep the JSON contract stable for tooling that consumes metadata output.","triggerScenarios":"Calling `cargo metadata --format-version 2` (or any value != 1). A tool/script hard-coding a newer format-version after reading outdated docs. Passing `--format-version 0`. `cargo_metadata` crate or IDE plugins requesting an unsupported version.","commonSituations":"Migrating tooling that assumed a v2 existed. Typos in wrapper scripts (`--format-version=1.0` parsed as non-1). Stale examples online referencing nonexistent versions. A new rustdoc/IDE plugin release expecting a bumped version that this cargo does not support (older cargo).","solutions":["Always pass `--format-version 1`.","If using the `cargo_metadata` crate, do not override the version; let it default.","Upgrade cargo if a genuinely newer schema is required (currently no v2 exists, so this usually means correcting the caller)."],"exampleFix":"# before\n$ cargo metadata --format-version 2   # error\n\n# after\n$ cargo metadata --format-version 1","handlingStrategy":"validation","validationCode":"const SUPPORTED: u32 = 1;\nfn assert_metadata_version(v: u32) -> Result<(), String> {\n    if v == SUPPORTED { Ok(()) } else { Err(format!(\"only format-version {} is supported\", SUPPORTED)) }\n}","typeGuard":"fn is_supported_metadata_version(v: u32) -> bool { v == 1 }","tryCatchPattern":null,"preventionTips":["Always invoke `cargo metadata --format-version 1`.","Prefer the `cargo_metadata` crate which handles the version for you.","Do not extrapolate that higher version numbers exist — only v1 is stable.","Pin the version constant in wrapper scripts from a single source of truth."],"tags":["metadata","versioning","cli-usage","json"],"backgroundTag":null,"analyzedSha":"eb98b54bc9f3c74519f43d066cb3fd02ebc88df0","analyzedAt":"2026-08-11T17:42:36.556Z","contentChangedAt":"2026-08-11T17:42:36.556Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}