diff --git a/src/cargo/core/workspace.rs b/src/cargo/core/workspace.rs index 870733f96d9..fa5a14e719c 100644 --- a/src/cargo/core/workspace.rs +++ b/src/cargo/core/workspace.rs @@ -304,15 +304,16 @@ impl<'cfg> Workspace<'cfg> { } fn find_path_deps(&mut self, manifest_path: &Path) -> CargoResult<()> { - if self.members.iter().any(|p| p == manifest_path) { + let manifest_path = paths::normalize_path(manifest_path); + if self.members.iter().any(|p| p == &manifest_path) { return Ok(()) } debug!("find_members - {}", manifest_path.display()); - self.members.push(manifest_path.to_path_buf()); + self.members.push(manifest_path.clone()); let candidates = { - let pkg = match *self.packages.load(manifest_path)? { + let pkg = match *self.packages.load(&manifest_path)? { MaybePackage::Package(ref p) => p, MaybePackage::Virtual(_) => return Ok(()), }; diff --git a/tests/workspaces.rs b/tests/workspaces.rs index 8204e6c341c..b84388813f1 100644 --- a/tests/workspaces.rs +++ b/tests/workspaces.rs @@ -1074,3 +1074,30 @@ fn error_if_parent_cargo_toml_is_invalid() { .with_stderr_contains("\ [ERROR] failed to parse manifest at `[..]`")); } + +#[test] +fn relative_path_for_member_works() { + let p = project("foo") + .file("foo/Cargo.toml", r#" + [project] + name = "foo" + version = "0.1.0" + authors = [] + + [workspace] + members = ["../bar"] + "#) + .file("foo/src/main.rs", "fn main() {}") + .file("bar/Cargo.toml", r#" + [project] + name = "bar" + version = "0.1.0" + authors = [] + workspace = "../foo" + "#) + .file("bar/src/main.rs", "fn main() {}"); + p.build(); + + assert_that(p.cargo("build").cwd(p.root().join("foo")), execs().with_status(0)); + assert_that(p.cargo("build").cwd(p.root().join("bar")), execs().with_status(0)); +} \ No newline at end of file