rust-lang/cargo · error

metadata version not supported, only is currently supported

Error message

metadata version {} not supported, only {} is currently supported

What it means

`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.

Solutions

  1. Always pass `--format-version 1`.
  2. If using the `cargo_metadata` crate, do not override the version; let it default.
  3. Upgrade cargo if a genuinely newer schema is required (currently no v2 exists, so this usually means correcting the caller).

Example fix

# before
$ cargo metadata --format-version 2   # error

# after
$ cargo metadata --format-version 1
Defensive patterns

Strategy: validation

Validate before calling

const SUPPORTED: u32 = 1;
fn assert_metadata_version(v: u32) -> Result<(), String> {
    if v == SUPPORTED { Ok(()) } else { Err(format!("only format-version {} is supported", SUPPORTED)) }
}

Type guard

fn is_supported_metadata_version(v: u32) -> bool { v == 1 }

Prevention

When it happens

Trigger: 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.

Common situations: 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).

Related errors


AI-assisted analysis of rust-lang/cargo@eb98b54bc9 (2026-08-11). Data as JSON: /api/errors/9f34c55a43dee4b0. Report an issue: GitHub.

Appendix: source

Thrown at src/ops/cargo_metadata.rs:29

use serde::Serialize;
use std::collections::BTreeMap;
use std::path::PathBuf;

const VERSION: u32 = 1;

pub struct OutputMetadataOptions {
    pub cli_features: CliFeatures,
    pub no_deps: bool,
    pub version: u32,
    pub filter_platforms: Vec<String>,
}

/// Loads the manifest, resolves the dependencies of the package to the concrete
/// used versions - considering overrides - and writes all dependencies in a JSON
/// format to stdout.
pub fn output_metadata(ws: &Workspace<'_>, opt: &OutputMetadataOptions) -> CargoResult<ExportInfo> {
    if opt.version != VERSION {
        anyhow::bail!(
            "metadata version {} not supported, only {} is currently supported",
            opt.version,
            VERSION
        );
    }
    let (packages, resolve) = if opt.no_deps {
        let packages = ws
            .members()
            .map(|pkg| pkg.serialized(ws.gctx().cli_unstable(), ws.unstable_features()))
            .collect();
        (packages, None)
    } else {
        let (packages, resolve) = build_resolve_graph(ws, opt)?;
        (packages, Some(resolve))
    };

    Ok(ExportInfo {
        packages,

View on GitHub (pinned to eb98b54bc9)