Skip to content

Commit 0bf7aaf

Browse files
committed
Auto merge of #7654 - ehuss:offline-hint, r=alexcrichton
Add a --offline hint. If `--locked` or `--frozen` is used, but the lock file needs to be built or updated, provide a hint for an alternate solution of using `--offline`. Closes #7584
2 parents 626f0f4 + 237051f commit 0bf7aaf

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/cargo/ops/lockfile.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ pub fn write_pkg_lockfile(ws: &Workspace<'_>, resolve: &Resolve) -> CargoResult<
5656
"--frozen"
5757
};
5858
failure::bail!(
59-
"the lock file {} needs to be updated but {} was passed to \
60-
prevent this",
59+
"the lock file {} needs to be updated but {} was passed to prevent this\n\
60+
If you want to try to generate the lock file without accessing the network, \
61+
use the --offline flag.",
6162
ws.root().to_path_buf().join("Cargo.lock").display(),
6263
flag
6364
);

tests/testsuite/lockfile_compat.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,7 @@ fn locked_correct_error() {
514514
"\
515515
[UPDATING] `[..]` index
516516
error: the lock file [CWD]/Cargo.lock needs to be updated but --locked was passed to prevent this
517+
If you want to try to generate the lock file without accessing the network, use the --offline flag.
517518
",
518519
)
519520
.run();

0 commit comments

Comments
 (0)