Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the correct flag in --locked --offline error message #10512

Merged
merged 2 commits into from
Mar 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}