diff --git a/src/cargo/ops/cargo_install.rs b/src/cargo/ops/cargo_install.rs index d25bf11ba18..616c7b35186 100644 --- a/src/cargo/ops/cargo_install.rs +++ b/src/cargo/ops/cargo_install.rs @@ -90,7 +90,10 @@ pub fn install(root: Option<&str>, Some(Filesystem::new(config.cwd().join("target-install"))) }; - let ws = try!(Workspace::one(pkg, config, overidden_target_dir)); + let ws = match overidden_target_dir { + Some(dir) => try!(Workspace::one(pkg, config, Some(dir))), + None => try!(Workspace::new(pkg.manifest_path(), config)), + }; let pkg = try!(ws.current()); // Preflight checks to check up front whether we'll overwrite something. diff --git a/tests/install.rs b/tests/install.rs index 5a9182a3242..6d064703fe2 100644 --- a/tests/install.rs +++ b/tests/install.rs @@ -793,3 +793,36 @@ fn readonly_dir() { execs().with_status(0)); assert_that(cargo_home(), has_installed_exe("foo")); } + +#[test] +fn use_path_workspace() { + Package::new("foo", "1.0.0").publish(); + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "bar" + version = "0.1.0" + authors = [] + + [workspace] + members = ["baz"] + "#) + .file("src/main.rs", "fn main() {}") + .file("baz/Cargo.toml", r#" + [package] + name = "baz" + version = "0.1.0" + authors = [] + + [dependencies] + foo = "1" + "#) + .file("baz/src/lib.rs", ""); + p.build(); + + assert_that(p.cargo("build"), execs().with_status(0)); + let lock = p.read_lockfile(); + assert_that(p.cargo("install"), execs().with_status(0)); + let lock2 = p.read_lockfile(); + assert!(lock == lock2, "different lockfiles"); +}