Cargo2nix Cargo.lock needs to be updated but --lock was passed

I’m managing a Rust project with a nix flake that uses cargo2nix. When trying to remove an obsolete cargo workspace from the project, I get errors such as

++ crate2nix generate -f ./Cargo.toml -o Cargo-generated.nix -h /nix/store/c72g0j0b71wl0zkh4s7ms9cfy9bfbjdr-mre-crate2nix/crate-hashes.json
Error: while retrieving metadata about ./Cargo.toml: `cargo metadata` exited with an error: error: the lock file /build/8dbin39hn72h04fv5rijx35zycvqg7yk-source/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.

Given that this happens deep in the bowels of cargo2nix, I cannot follow the advice to fiddle with --locked and --offline flags.

How should I proceed in such situations?

Not a crate2nix user, but looking at the error messages, maybe running stuff like cargo build once would help

btw crate2nix and cargo2nix are two different projects

Ah, yes, that’s a typo resulting from an outdated comment in my code. Thanks for pointing it out.

1 Like