Skip to content

Incorrect flag in --locked --offline error message #10504

Closed
@QSchulz

Description

@QSchulz

Problem

Trying to build a crate with:

cargo build --locked --offline

when no Cargo.lock file is provided in the crate source repository leads to the following error message:

error: the lock file /path/to/Cargo.lock needs to be updated but --frozen was passed to prevent this
If you want to try to generate the lock file without accessing the network, remove the --frozen flag and use --offline instead.

It should mention --locked and not --frozen.

Steps

No response

Possible Solution(s)

https://github.com/rust-lang/cargo/blob/master/src/cargo/ops/lockfile.rs#L50-L54

        let flag = if ws.config().network_allowed() {
            "--locked"
        } else {
            "--frozen"
        };

could actually be:

        let flag = if ws.config().locked() {
            "--locked"
        } else {
            "--frozen"
        };

Notes

(Never done rust and didn't compile the suggestion)

The absence of Cargo.lock file shouldn't matter to reproduce the bug but it's an easy way to reproduce it.

Version

No response

Metadata

Metadata

Assignees

Labels

C-bugCategory: bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions