FuelLabs/sway · error
failed to construct path for dependency {:?}: {}
Error message
failed to construct path for dependency {:?}: {} What it means
A wrapper produced while validating one graph edge: dep_path() failed while resolving where the dependency lives on disk, and {} carries the real reason. Typical inner causes: 'cannot find dependency in the workspace', 'no dependency or patch with name ... in manifest of ...', or a missing Forc.toml inside a path dependency's directory.
Source
Thrown at forc-pkg/src/pkg.rs:1009
remove
}
/// Check the validity of a node's dependency within the graph.
///
/// Returns the `ManifestFile` in the case that the dependency is valid.
fn validate_dep(
graph: &Graph,
manifests: &MemberManifestFiles,
dep_edge: &Edge,
dep_node: NodeIx,
) -> Result<PackageManifestFile> {
let dep_name = &dep_edge.name;
let node_manifest = manifests
.get(dep_name)
.ok_or_else(|| anyhow!("Couldn't find manifest file for {}", dep_name))?;
// Check the validity of the dependency path, including its path root.
let dep_path = dep_path(graph, node_manifest, dep_node, manifests).map_err(|e| {
anyhow!(
"failed to construct path for dependency {:?}: {}",
dep_name,
e
)
})?;
// Ensure the manifest is accessible.
let dep_manifest = PackageManifestFile::from_dir(&dep_path)?;
// Check that the dependency's source matches the entry in the parent manifest.
let dep_entry = node_manifest
.dep(dep_name)
.ok_or_else(|| anyhow!("no entry in parent manifest"))?;
let dep_source =
Source::from_manifest_dep_patched(node_manifest, dep_name, dep_entry, manifests)?;
let dep_pkg = graph[dep_node].unpinned(&dep_path);
if dep_pkg.source != dep_source {
bail!("dependency node's source does not match manifest entry");View on GitHub (pinned to 47e5e902fa)
Solutions
- Read the inner {} message - it names the specific sub-cause; fix that first.
- Verify each path dependency directory exists and contains a Forc.toml.
- Run 'git submodule update --init --recursive' if dependencies are submodules.
- Check spelling of member/dependency names and that the IPFS node or network is reachable for remote dependencies.
Example fix
# before: path moved
[dependencies]
lib = { path = "../old-location/lib" }
# after
[dependencies]
lib = { path = "../libs/lib" } Defensive patterns
Strategy: try-catch
Validate before calling
// for each path dependency, require the target to contain a manifest
for (name, dep) in pkg_manifest.dependencies() {
if let Some(p) = dep.path() {
let dir = manifest_dir.join(&p);
if !dir.join("Forc.toml").is_file() {
return Err(format!("path dependency '{name}' has no Forc.toml at {}", dir.display()));
}
}
} Try / catch
if let Err(e) = build_plan_result {
for cause in anyhow::Error::chain(&e) {
let s = cause.to_string();
if s.starts_with("failed to construct path for dependency") {
// inspect the inner cause: missing member, missing Forc.toml, absent patch
diagnostics.push(s);
}
}
} Prevention
- Run 'git submodule update --init --recursive' before building repos with vendored deps.
- Keep path entries relative and verify the folders exist in CI.
- Make dependency keys match member names exactly.
When it happens
Trigger: A path dependency whose directory no longer contains Forc.toml (moved folder, missing submodule); a dependency treated as a workspace member whose name is not found; patch target missing; offline fetch of a git/ipfs dependency surfacing here.
Common situations: Moving or renaming a path-dependency folder without updating Forc.toml; forgetting 'git submodule update --init --recursive'; typos in member names; network/IPFS node unavailable for remote deps.
Related errors
- Failed to find path root: `path` dependency \"{}\" has no pa
- Cannot get parent dir of {:?}
- graph contains no project node
- graph contains more than one project node
- Couldn't find manifest file for {}
AI-assisted analysis of FuelLabs/sway@47e5e902fa (2026-08-16).
Data as JSON: /api/errors/d7e1e1630a294b51.
Report an issue: GitHub.