{"id":"cd75bc3cf7a20a5f","repo":"rust-lang/cargo","slug":"lock-file-version-n-requires-znext-lockfile","errorCode":null,"errorMessage":"lock file version `{n}` requires `-Znext-lockfile-bump`","messagePattern":"lock file version `(.+?)` requires `-Znext-lockfile-bump`","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/resolver/encode.rs","lineNumber":149,"sourceCode":"/// dependencies do not know the difference between regular/dev/build\n/// dependencies, so they are not filled in. It also does not include\n/// `features`. Care should be taken when using this Resolve. One of the\n/// primary uses is to be used with `resolve_with_previous` to guide the\n/// resolver to create a complete Resolve.\npub fn into_resolve(\n    resolve: TomlLockfile,\n    original: &str,\n    ws: &Workspace<'_>,\n) -> CargoResult<Resolve> {\n    let path_deps: HashMap<String, HashMap<semver::Version, SourceId>> = build_path_deps(ws)?;\n    let mut checksums = HashMap::default();\n\n    let mut version = match resolve.version {\n        Some(n @ 5) if ws.gctx().nightly_features_allowed => {\n            if ws.gctx().cli_unstable().next_lockfile_bump {\n                ResolveVersion::V5\n            } else {\n                anyhow::bail!(\"lock file version `{n}` requires `-Znext-lockfile-bump`\");\n            }\n        }\n        Some(4) => ResolveVersion::V4,\n        Some(3) => ResolveVersion::V3,\n        Some(n) => bail!(\n            \"lock file version `{}` was found, but this version of Cargo \\\n             does not understand this lock file, perhaps Cargo needs \\\n             to be updated?\",\n            n,\n        ),\n        // Historically Cargo did not have a version indicator in lock\n        // files, so this could either be the V1 or V2 encoding. We assume\n        // an older format is being parsed until we see so otherwise.\n        None => ResolveVersion::V1,\n    };\n\n    let packages = {\n        let mut packages = resolve.package.unwrap_or_default();","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/rust-lang/cargo/blob/0e07a155371a6ce88ae53a2c00df940280c09a67/src/resolver/encode.rs#L131-L167","documentation":"Thrown by `into_resolve` while parsing `Cargo.lock`: the lockfile declares `version = 5`, but Cargo only accepts V5 when both nightly features are allowed (`gctx().nightly_features_allowed`) and the `-Znext-lockfile-bump` unstable flag is passed. Without the flag, a V5 lockfile is refused to prevent silent behavior divergence between stable and nightly.","triggerScenarios":"Opening a project whose `Cargo.lock` was generated by a newer/nightly Cargo that wrote `version = 5`, using a Cargo build that lacks the `next-lockfile_bump` unstable feature. The `match` arm `Some(n @ 5)` with `nightly_features_allowed` true but `cli_unstable().next_lockfile_bump` false bails.","commonSituations":"Switching between stable and nightly toolchains; CI using stable Rust against a repo committed by a nightly user; checking out a repo whose lockfile was auto-bumped by a newer Cargo; downgrading Cargo after an upgrade.","solutions":["Run with the nightly toolchain and the unstable flag: `cargo +nightly -Znext-lockfile-bump build`.","Upgrade your Cargo/Rust toolchain to a version that stabilizes V5 lockfiles.","Delete `Cargo.lock` and regenerate it with your current Cargo (only if dependency reproducibility across the team is not a concern).","Pin the team to a single Rust/Cargo version to avoid lockfile-version churn."],"exampleFix":"# before (stable cargo)\ncargo build\n# after\ncargo +nightly -Znext-lockfile-bump build","handlingStrategy":"validation","validationCode":"# Pin the toolchain so Cargo.lock version stays consistent across the team:\n# rust-toolchain.toml\n[toolchain]\nchannel = \"1.75\"  # or a nightly that supports the needed lockfile version\n\n# Detect V5 lockfiles before building:\ngrep -q '^version = 5' Cargo.lock && echo 'needs -Znext-lockfile-bump or newer Cargo'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Commit a `rust-toolchain.toml` to unify Cargo versions across the team and CI.","Avoid committing lockfiles generated by a newer nightly into a stable-target repo.","In CI, fail fast if `Cargo.lock` version exceeds what the pinned Cargo supports."],"tags":["lockfile","nightly","version","toolchain"],"analyzedSha":"0e07a155371a6ce88ae53a2c00df940280c09a67","analyzedAt":"2026-08-06T01:46:58.334Z","schemaVersion":2}