{"record":{"id":"6da7c79ba4db01ea","repo":"FuelLabs/sway","slug":"graph-contains-no-project-node","errorCode":null,"errorMessage":"graph contains no project node","messagePattern":"graph contains no project node","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"forc-pkg/src/pkg.rs","lineNumber":893,"sourceCode":"}\n\n/// Given a graph and the known project name retrieved from the manifest, produce an iterator\n/// yielding any nodes from the graph that might potentially be a project node.\nfn potential_proj_nodes<'a>(g: &'a Graph, proj_name: &'a str) -> impl 'a + Iterator<Item = NodeIx> {\n    member_nodes(g).filter(move |&n| g[n].name == proj_name)\n}\n\n/// Given a graph, find the project node.\n///\n/// This should be the only node that satisfies the following conditions:\n///\n/// - The package name matches `proj_name`\n/// - The node has no incoming edges, i.e. is not a dependency of another node.\nfn find_proj_node(graph: &Graph, proj_name: &str) -> Result<NodeIx> {\n    let mut potentials = potential_proj_nodes(graph, proj_name);\n    let proj_node = potentials\n        .next()\n        .ok_or_else(|| anyhow!(\"graph contains no project node\"))?;\n    match potentials.next() {\n        None => Ok(proj_node),\n        Some(_) => Err(anyhow!(\"graph contains more than one project node\")),\n    }\n}\n\n/// Checks if the toolchain version is in compliance with minimum implied by `manifest`.\n///\n/// If the `manifest` is a ManifestFile::Workspace, check all members of the workspace for version\n/// validation. Otherwise only the given package is checked.\nfn validate_version(member_manifests: &MemberManifestFiles) -> Result<()> {\n    for member_pkg_manifest in member_manifests.values() {\n        validate_pkg_version(member_pkg_manifest)?;\n    }\n    Ok(())\n}\n\n/// Check minimum forc version given in the package manifest file","sourceCodeStart":875,"sourceCodeEnd":911,"githubUrl":"https://github.com/FuelLabs/sway/blob/47e5e902faa42baf652dd6a0c88cd23390c1a614/forc-pkg/src/pkg.rs#L875-L911","documentation":"find_proj_node scans the dependency graph for the unique node whose name equals proj_name and that has no incoming edges (nothing depends on it). Zero matches produce this error: the package being built is not present as a root in the graph. Typically the project name in Forc.toml no longer agrees with what the lock/graph contains, or every occurrence of the package is consumed as a dependency of another node.","triggerScenarios":"pkg_graph_to_manifest_map called with a pkg_name that matches no graph node; the member was renamed in [project] name while Forc.lock still reflects the old name; the project depends on a package with the same name so both nodes have incoming edges; stale lock after workspace restructuring.","commonSituations":"Renaming a package without regenerating Forc.lock; two workspace members sharing a name; partially applied workspace reorganizations.","solutions":["Delete Forc.lock and rebuild so the graph is regenerated from current manifests.","Verify the package's [project] name is unique across the workspace and matches how dependents reference it.","Run 'forc update' to resynchronize manifest and lock."],"exampleFix":"# before\nforc build   # graph contains no project node\n\n# after\nrm Forc.lock && forc build","handlingStrategy":"validation","validationCode":"let names: std::collections::HashSet<String> =\n    member_manifests.values().map(|m| m.project.name.clone()).collect();\nif !names.contains(&proj_name) {\n    // the build root is not among the loaded members: fix names or regenerate the lock\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["After renaming a package, regenerate Forc.lock immediately.","Keep the project name consistent between Forc.toml and how dependents reference it.","Run 'forc check' after workspace restructures before full builds."],"tags":["graph","manifest","workspace","lock-file"],"backgroundTag":null,"analyzedSha":"47e5e902faa42baf652dd6a0c88cd23390c1a614","analyzedAt":"2026-08-16T07:57:45.555Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}