Skip to content
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
6 changes: 3 additions & 3 deletions src/cargo/ops/lockfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ pub fn write_pkg_lockfile(ws: &Workspace<'_>, resolve: &mut Resolve) -> CargoRes
if let Some(locked_flag) = ws.gctx().locked_flag() {
let lockfile_path = lock_root.as_path_unlocked().join(LOCKFILE_NAME);
let action = if lockfile_path.exists() {
"updated"
"update"
} else {
"created"
"create"
};
let lockfile_path = lockfile_path.display();
anyhow::bail!(
"the lock file {lockfile_path} needs to be {action} but {locked_flag} was passed to prevent this\n\
"cannot {action} the lock file {lockfile_path} because {locked_flag} was passed to prevent this\n\
help: to generate the lock file without accessing the network, \
remove the {locked_flag} flag and use --offline instead."
);
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/lockfile_compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ fn locked_correct_error() {
.with_status(101)
.with_stderr_data(str![[r#"
[UPDATING] `dummy-registry` index
[ERROR] the lock file [ROOT]/foo/Cargo.lock needs to be created but --locked was passed to prevent this
[ERROR] cannot create the lock file [ROOT]/foo/Cargo.lock because --locked was passed to prevent this
[HELP] to generate the lock file without accessing the network, remove the --locked flag and use --offline instead.

"#]])
Expand Down
4 changes: 2 additions & 2 deletions tests/testsuite/offline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ fn offline_and_frozen_and_no_lock() {
p.cargo("check --frozen --offline")
.with_status(101)
.with_stderr_data(str![[r#"
[ERROR] the lock file [ROOT]/foo/Cargo.lock needs to be created but --frozen was passed to prevent this
[ERROR] cannot create the lock file [ROOT]/foo/Cargo.lock because --frozen was passed to prevent this
[HELP] to generate the lock file without accessing the network, remove the --frozen flag and use --offline instead.

"#]])
Expand All @@ -780,7 +780,7 @@ fn offline_and_locked_and_no_frozen() {
p.cargo("check --locked --offline")
.with_status(101)
.with_stderr_data(str![[r#"
[ERROR] the lock file [ROOT]/foo/Cargo.lock needs to be created but --locked was passed to prevent this
[ERROR] cannot create the lock file [ROOT]/foo/Cargo.lock because --locked was passed to prevent this
[HELP] to generate the lock file without accessing the network, remove the --locked flag and use --offline instead.

"#]])
Expand Down