Skip to content

Commit 3c6a6e4

Browse files
committed
Auto merge of #10512 - hi-rustin:rustin-patch-offline, r=epage
Use the correct flag in --locked --offline error message ### What does this PR try to resolve? close #10504 [Use the correct the flag in --locked --offline error message](17ec415) [Add offline_and_locked_and_no_frozen test](7363f43) ### How should we test and review this PR? - unit test
2 parents aefc3cf + 7363f43 commit 3c6a6e4

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/cargo/ops/lockfile.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub fn write_pkg_lockfile(ws: &Workspace<'_>, resolve: &mut Resolve) -> CargoRes
4747
}
4848

4949
if !ws.config().lock_update_allowed() {
50-
let flag = if ws.config().network_allowed() {
50+
let flag = if ws.config().locked() {
5151
"--locked"
5252
} else {
5353
"--frozen"

tests/testsuite/offline.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,3 +700,16 @@ remove the --frozen flag and use --offline instead.
700700
")
701701
.run();
702702
}
703+
704+
#[cargo_test]
705+
fn offline_and_locked_and_no_frozen() {
706+
let p = project().file("src/lib.rs", "").build();
707+
p.cargo("build --locked --offline")
708+
.with_status(101)
709+
.with_stderr("\
710+
error: the lock file [ROOT]/foo/Cargo.lock needs to be updated but --locked was passed to prevent this
711+
If you want to try to generate the lock file without accessing the network, \
712+
remove the --locked flag and use --offline instead.
713+
")
714+
.run();
715+
}

0 commit comments

Comments
 (0)