Skip to content

Commit eae8900

Browse files
committed
Make --locked required for cargo install --path, too.
1 parent c03c85a commit eae8900

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/cargo/ops/cargo_install.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,18 +215,15 @@ fn install_one(
215215
Some(Filesystem::new(config.cwd().join("target-install")))
216216
};
217217

218-
let ws = match overidden_target_dir {
219-
Some(dir) => {
220-
let mut ws = Workspace::ephemeral(pkg, config, Some(dir), false)?;
221-
ws.set_ignore_lock(config.lock_update_allowed());
222-
ws
223-
}
218+
let mut ws = match overidden_target_dir {
219+
Some(dir) => Workspace::ephemeral(pkg, config, Some(dir), false)?,
224220
None => {
225221
let mut ws = Workspace::new(pkg.manifest_path(), config)?;
226222
ws.set_require_optional_deps(false);
227223
ws
228224
}
229225
};
226+
ws.set_ignore_lock(config.lock_update_allowed());
230227
let pkg = ws.current()?;
231228

232229
if from_cwd {

tests/testsuite/install.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,8 +1190,7 @@ fn custom_target_dir_for_git_source() {
11901190

11911191
#[test]
11921192
fn install_respects_lock_file() {
1193-
// `cargo install` now requires --locked to use a Cargo.lock for non
1194-
// --path installs.
1193+
// `cargo install` now requires --locked to use a Cargo.lock.
11951194
Package::new("bar", "0.1.0").publish();
11961195
Package::new("bar", "0.1.1")
11971196
.file("src/lib.rs", "not rust")
@@ -1230,7 +1229,8 @@ dependencies = [
12301229

12311230
#[test]
12321231
fn install_path_respects_lock_file() {
1233-
// For --path installs, always use local Cargo.lock.
1232+
// --path version of install_path_respects_lock_file, --locked is required
1233+
// to use Cargo.lock.
12341234
Package::new("bar", "0.1.0").publish();
12351235
Package::new("bar", "0.1.1")
12361236
.file("src/lib.rs", "not rust")
@@ -1266,7 +1266,11 @@ dependencies = [
12661266
)
12671267
.build();
12681268

1269-
p.cargo("install --path .").run();
1269+
p.cargo("install --path .")
1270+
.with_stderr_contains("[..]not rust[..]")
1271+
.with_status(101)
1272+
.run();
1273+
p.cargo("install --path . --locked").run();
12701274
}
12711275

12721276
#[test]

0 commit comments

Comments
 (0)