diff --git a/CHANGELOG.md b/CHANGELOG.md index ca1ce2f45..8e805eea7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed +- Fixed `ERROR: The workspace root package should be a workspace member` when building contract under Windows - [#261](https://github.com/paritytech/cargo-contract/pull/261) + ### Removed - Remove support for `--binaryen-as-dependency` - [#251](https://github.com/paritytech/cargo-contract/pull/251) diff --git a/src/workspace/mod.rs b/src/workspace/mod.rs index 7f242d2a0..ece11fb27 100644 --- a/src/workspace/mod.rs +++ b/src/workspace/mod.rs @@ -108,14 +108,24 @@ impl Workspace { .members .iter_mut() .find_map(|(_, (_, manifest))| { - if manifest.path().directory() == Some(package_path) { + /// `package_path` is always absolute and canonicalized. Thus we need to + /// canonicalize the manifest's directory path as well in order to compare + /// both of them. + let manifest_path = manifest.path().directory()?; + let manifest_path = manifest_path + .canonicalize() + .unwrap_or_else(|_| panic!("Cannot canonicalize {}", manifest_path.display())); + if manifest_path == package_path { Some(manifest) } else { None } }) .ok_or_else(|| { - anyhow::anyhow!("The workspace root package should be a workspace member") + anyhow::anyhow!( + "Cannot find package with package path {} in members", + package_path.display(), + ) })?; f(manifest)?; Ok(self)