Skip to content

Commit

Permalink
Auto merge of #10512 - hi-rustin:rustin-patch-offline, r=epage
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Mar 30, 2022
2 parents aefc3cf + 7363f43 commit 3c6a6e4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cargo/ops/lockfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub fn write_pkg_lockfile(ws: &Workspace<'_>, resolve: &mut Resolve) -> CargoRes
}

if !ws.config().lock_update_allowed() {
let flag = if ws.config().network_allowed() {
let flag = if ws.config().locked() {
"--locked"
} else {
"--frozen"
Expand Down
13 changes: 13 additions & 0 deletions tests/testsuite/offline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -700,3 +700,16 @@ remove the --frozen flag and use --offline instead.
")
.run();
}

#[cargo_test]
fn offline_and_locked_and_no_frozen() {
let p = project().file("src/lib.rs", "").build();
p.cargo("build --locked --offline")
.with_status(101)
.with_stderr("\
error: the lock file [ROOT]/foo/Cargo.lock needs to be updated but --locked was passed to prevent this
If you want to try to generate the lock file without accessing the network, \
remove the --locked flag and use --offline instead.
")
.run();
}

0 comments on commit 3c6a6e4

Please sign in to comment.