From eae89007a6d529d51f7474d642835f0273353557 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 13 Apr 2019 16:43:53 -0700 Subject: [PATCH] Make --locked required for `cargo install --path`, too. --- src/cargo/ops/cargo_install.rs | 9 +++------ tests/testsuite/install.rs | 12 ++++++++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/cargo/ops/cargo_install.rs b/src/cargo/ops/cargo_install.rs index d891ea5c4..a9ee557a0 100644 --- a/src/cargo/ops/cargo_install.rs +++ b/src/cargo/ops/cargo_install.rs @@ -215,18 +215,15 @@ fn install_one( Some(Filesystem::new(config.cwd().join("target-install"))) }; - let ws = match overidden_target_dir { - Some(dir) => { - let mut ws = Workspace::ephemeral(pkg, config, Some(dir), false)?; - ws.set_ignore_lock(config.lock_update_allowed()); - ws - } + let mut ws = match overidden_target_dir { + Some(dir) => Workspace::ephemeral(pkg, config, Some(dir), false)?, None => { let mut ws = Workspace::new(pkg.manifest_path(), config)?; ws.set_require_optional_deps(false); ws } }; + ws.set_ignore_lock(config.lock_update_allowed()); let pkg = ws.current()?; if from_cwd { diff --git a/tests/testsuite/install.rs b/tests/testsuite/install.rs index ada9f3f5c..e3fb49d12 100644 --- a/tests/testsuite/install.rs +++ b/tests/testsuite/install.rs @@ -1190,8 +1190,7 @@ fn custom_target_dir_for_git_source() { #[test] fn install_respects_lock_file() { - // `cargo install` now requires --locked to use a Cargo.lock for non - // --path installs. + // `cargo install` now requires --locked to use a Cargo.lock. Package::new("bar", "0.1.0").publish(); Package::new("bar", "0.1.1") .file("src/lib.rs", "not rust") @@ -1230,7 +1229,8 @@ dependencies = [ #[test] fn install_path_respects_lock_file() { - // For --path installs, always use local Cargo.lock. + // --path version of install_path_respects_lock_file, --locked is required + // to use Cargo.lock. Package::new("bar", "0.1.0").publish(); Package::new("bar", "0.1.1") .file("src/lib.rs", "not rust") @@ -1266,7 +1266,11 @@ dependencies = [ ) .build(); - p.cargo("install --path .").run(); + p.cargo("install --path .") + .with_stderr_contains("[..]not rust[..]") + .with_status(101) + .run(); + p.cargo("install --path . --locked").run(); } #[test]