{"record":{"id":"9d8033c0b87c59a1","repo":"FuelLabs/sway","slug":"lock-file-did-not-match-manifest","errorCode":null,"errorMessage":"lock file did not match manifest","messagePattern":"lock file did not match manifest","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"forc-pkg/src/pkg.rs","lineNumber":728,"sourceCode":"        let mut manifest_map = graph_to_manifest_map(manifests, &graph)?;\n\n        // Attempt to fetch the remainder of the graph.\n        let _added = fetch_graph(manifests, offline, ipfs_node, &mut graph, &mut manifest_map)?;\n\n        // Determine the compilation order.\n        let compilation_order = compilation_order(&graph)?;\n\n        let plan = Self {\n            graph,\n            manifest_map,\n            compilation_order,\n        };\n\n        // Construct the new lock and check the diff.\n        let new_lock = Lock::from_graph(plan.graph());\n        let lock_diff = new_lock.diff(&lock);\n        if !lock_diff.removed.is_empty() || !lock_diff.added.is_empty() {\n            new_lock_cause.get_or_insert(anyhow!(\"lock file did not match manifest\"));\n        }\n\n        // If there was some change in the lock file, write the new one and print the cause.\n        if let Some(cause) = new_lock_cause {\n            if locked {\n                bail!(\n                    \"The lock file {} needs to be updated (Cause: {}) \\\n                    but --locked was passed to prevent this.\",\n                    lock_path.to_string_lossy(),\n                    cause,\n                );\n            }\n            println_action_green(\n                \"Creating\",\n                &format!(\"a new `Forc.lock` file. (Cause: {cause})\"),\n            );\n            let member_names = manifests\n                .values()","sourceCodeStart":710,"sourceCodeEnd":746,"githubUrl":"https://github.com/FuelLabs/sway/blob/47e5e902faa42baf652dd6a0c88cd23390c1a614/forc-pkg/src/pkg.rs#L710-L746","documentation":"After the package graph is rebuilt from the member manifests, forc computes Lock::from_graph and diffs it against the on-disk lock; if packages were added or removed, this cause is recorded. The manifests and the lock disagree about the dependency set - normally forc rewrites Forc.lock, but with --locked it bails.","triggerScenarios":"Adding, removing or renaming a dependency or workspace member in Forc.toml without regenerating the lock; changing a path dependency location; switching git branches where Forc.toml changed but Forc.lock did not; running with --locked afterwards.","commonSituations":"Pull/merge updated manifests in one branch but not the lock; a teammate committed Forc.toml without Forc.lock; CI running --locked right after dependency changes.","solutions":["Run one build (or 'forc update') without --locked to sync, then commit the updated Forc.lock.","If the diff is unexpected, inspect 'git diff Forc.lock' to find which manifest change caused it.","Make it a habit to commit Forc.toml and Forc.lock together in the same change."],"exampleFix":"# before\nforc build --locked   # lock file did not match manifest\n\n# after\ngit add Forc.toml Forc.lock && git commit -m \"feat: add dependency\"\nforc build --locked","handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\n# fail early if the lock is out of sync with the manifests\nforc build\ngit diff --quiet Forc.lock || { echo \"Forc.lock is out of date; commit the update\"; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Commit Forc.toml and Forc.lock together in the same change.","After pulling or merging, run a plain 'forc build' once before any --locked step.","Add a lock-freshness check step in CI before the --locked build."],"tags":["lock-file","manifest","dependencies","ci"],"backgroundTag":null,"analyzedSha":"47e5e902faa42baf652dd6a0c88cd23390c1a614","analyzedAt":"2026-08-16T07:57:45.555Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}