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
- 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).
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
- 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.
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
- can't specify both lib and binary outputs
- cannot create package in the home directory help: use…
- cannot open specified crate's documentation: no…
- `cargo init` cannot be run on existing Cargo packages help…
- destination ` ` already exists Use `cargo init` to…
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)