Skip to content

Commit

Permalink
Handle removed dep in manifest during path reconstruction from graph (F…
Browse files Browse the repository at this point in the history
…uelLabs#1314)

This fixes a bug where removing a path dependency (e.g. core) from the
manifest where that dependency is shared by another dependency (e.g.
std) could cause path map reconstruction to fail.

Previously, we assumed that the dependency would be present within the
manifest in order to retrieve the source path. This PR removes this
assumption and will instead reconstruct the dependency graph (and in
turn the lock file) when a dependency is discovered to be missing during
path reconstruction.

First spotted by @nfurfaro [here][1].

[1]: https://github.com/FuelLabs/sway/pull/1276/files#r853131667
  • Loading branch information
mitchmindtree authored Apr 20, 2022
1 parent 44cea40 commit a79da8c
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions forc-pkg/src/pkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,11 +536,19 @@ pub fn graph_to_path_map(
let detailed = parent_manifest
.dependencies
.as_ref()
.and_then(|deps| match &deps[&dep_name] {
Dependency::Detailed(detailed) => Some(detailed),
Dependency::Simple(_) => None,
.and_then(|deps| deps.get(&dep_name))
.ok_or_else(|| {
anyhow!(
"dependency required for path reconstruction \
has been removed from the manifest"
)
})
.ok_or_else(|| anyhow!("missing path info for dependency: {}", dep.name))?;
.and_then(|dep| match dep {
Dependency::Detailed(detailed) => Ok(detailed),
Dependency::Simple(_) => {
bail!("missing path info for dependency: {}", &dep_name);
}
})?;
let rel_dep_path = detailed
.path
.as_ref()
Expand Down

0 comments on commit a79da8c

Please sign in to comment.