Skip to content

Commit 7400f24

Browse files
committed
Use workspaces during cargo install
Prevent lock files from oscillating. Closes #3133
1 parent d8936af commit 7400f24

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/cargo/ops/cargo_install.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@ pub fn install(root: Option<&str>,
9090
Some(Filesystem::new(config.cwd().join("target-install")))
9191
};
9292

93-
let ws = try!(Workspace::one(pkg, config, overidden_target_dir));
93+
let ws = match overidden_target_dir {
94+
Some(dir) => try!(Workspace::one(pkg, config, Some(dir))),
95+
None => try!(Workspace::new(pkg.manifest_path(), config)),
96+
};
9497
let pkg = try!(ws.current());
9598

9699
// Preflight checks to check up front whether we'll overwrite something.

tests/install.rs

+33
Original file line numberDiff line numberDiff line change
@@ -793,3 +793,36 @@ fn readonly_dir() {
793793
execs().with_status(0));
794794
assert_that(cargo_home(), has_installed_exe("foo"));
795795
}
796+
797+
#[test]
798+
fn use_path_workspace() {
799+
Package::new("foo", "1.0.0").publish();
800+
let p = project("foo")
801+
.file("Cargo.toml", r#"
802+
[package]
803+
name = "bar"
804+
version = "0.1.0"
805+
authors = []
806+
807+
[workspace]
808+
members = ["baz"]
809+
"#)
810+
.file("src/main.rs", "fn main() {}")
811+
.file("baz/Cargo.toml", r#"
812+
[package]
813+
name = "baz"
814+
version = "0.1.0"
815+
authors = []
816+
817+
[dependencies]
818+
foo = "1"
819+
"#)
820+
.file("baz/src/lib.rs", "");
821+
p.build();
822+
823+
assert_that(p.cargo("build"), execs().with_status(0));
824+
let lock = p.read_lockfile();
825+
assert_that(p.cargo("install"), execs().with_status(0));
826+
let lock2 = p.read_lockfile();
827+
assert!(lock == lock2, "different lockfiles");
828+
}

0 commit comments

Comments
 (0)