{"record":{"id":"608e888fd614a420","repo":"FuelLabs/sway","slug":"lock-file-did-not-exist","errorCode":null,"errorMessage":"lock file did not exist","messagePattern":"lock file did not exist","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"forc-pkg/src/pkg.rs","lineNumber":686,"sourceCode":"    // probably should not be the role of the `BuildPlan` constructor - instead, we should return\n    // the manifest alongside some lock diff type that can be used to optionally write the updated\n    // lock file and print the diff.\n    pub fn from_lock_and_manifests(\n        lock_path: &Path,\n        manifests: &MemberManifestFiles,\n        locked: bool,\n        offline: bool,\n        ipfs_node: &IPFSNode,\n    ) -> Result<Self> {\n        // Check toolchain version\n        validate_version(manifests)?;\n        // Keep track of the cause for the new lock file if it turns out we need one.\n        let mut new_lock_cause = None;\n\n        // First, attempt to load the lock.\n        let lock = Lock::from_path(lock_path).unwrap_or_else(|e| {\n            new_lock_cause = if e.to_string().contains(\"No such file or directory\") {\n                Some(anyhow!(\"lock file did not exist\"))\n            } else {\n                Some(e)\n            };\n            Lock::default()\n        });\n\n        // Next, construct the package graph from the lock.\n        let mut graph = lock.to_graph().unwrap_or_else(|e| {\n            new_lock_cause = Some(anyhow!(\"Invalid lock: {}\", e));\n            Graph::default()\n        });\n\n        // Since the lock file was last created there are many ways in which it might have been\n        // invalidated. E.g. a package's manifest `[dependencies]` table might have changed, a user\n        // might have edited the `Forc.lock` file when they shouldn't have, a path dependency no\n        // longer exists at its specified location, etc. We must first remove all invalid nodes\n        // before we can determine what we need to fetch.\n        let invalid_deps = validate_graph(&graph, manifests)?;","sourceCodeStart":668,"sourceCodeEnd":704,"githubUrl":"https://github.com/FuelLabs/sway/blob/47e5e902faa42baf652dd6a0c88cd23390c1a614/forc-pkg/src/pkg.rs#L668-L704","documentation":"Recorded in BuildPlan::from_lock_and_manifests when Lock::from_path fails with 'No such file or directory'. It is not returned directly: it is stored as new_lock_cause and normally leads to 'Creating a new Forc.lock file (Cause: lock file did not exist)'. It only becomes a hard failure when --locked was passed, in which case forc bails with 'The lock file ... needs to be updated (Cause: lock file did not exist)'.","triggerScenarios":"First build of a project (no Forc.lock yet); Forc.lock deleted by forc clean or by hand; Forc.lock gitignored in a fresh clone; any of these combined with the locked flag (e.g. 'forc build --locked' or locked fetches in CI).","commonSituations":"CI pipelines that use --locked to enforce reproducibility on a repo whose Forc.lock was never committed; templates that gitignore Forc.lock; fresh clones by new contributors.","solutions":["Build once without --locked to generate Forc.lock, then commit it to version control.","If you intentionally do not track the lock, remove --locked from the command/CI job.","Check .gitignore does not exclude Forc.lock when reproducibility is required."],"exampleFix":"# before (fails when Forc.lock is absent)\nforc build --locked\n\n# after\ngit add Forc.lock && git commit -m \"chore: track Forc.lock\"\nforc build --locked","handlingStrategy":"validation","validationCode":"let lock = std::path::Path::new(\"Forc.lock\");\nif !lock.exists() {\n    // generate it before any --locked run:\n    //   forc build && git add Forc.lock && git commit\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Commit Forc.lock to version control for applications and contracts.","Only pass --locked in CI after verifying the lock is present in the repo.","Do not gitignore Forc.lock if you need reproducible builds."],"tags":["lock-file","forc","build","ci"],"backgroundTag":null,"analyzedSha":"47e5e902faa42baf652dd6a0c88cd23390c1a614","analyzedAt":"2026-08-16T07:57:45.555Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}