Skip to content

Commit

Permalink
Ensure path is always canonicalized for comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
cmichi committed Apr 19, 2021
1 parent 1b1f68e commit 3dcc1e5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
14 changes: 12 additions & 2 deletions src/workspace/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3dcc1e5

Please sign in to comment.