CARGO-GENERATE-LOCKFILE(1)
CARGO-GENERATE-LOCKFILE(1) π
okay bestie, this is a page from the General Commands Manual β the whole cargo-generate-lockfile situation. let's get into it, no cap.
β¨ NAME β¨
cargo-generate-lockfile β Generate the lockfile for a package π
πΈ SYNOPSIS πΈ
cargo generate-lockfile [options]
π¦ DESCRIPTION π¦
so basically, this command creates the Cargo.lock lockfile for your current package or workspace. that's it, that's the job. β¨
and if the lockfile is already there? it gets rebuilt with the latest available version of every single package. so it's giving "glow up" energy, not "start from scratch" energy. π
also, lowkey important: go look at cargo-update(1) too, bestie. it can also create a Cargo.lock lockfile, and it has way more options for controlling the update behavior. so if you need finer control, that's your girl. π
π OPTIONS π
π Display Options π
-v,--verboseβ use verbose output. and yes, you can specify it twice for "very verbose" output, which includes extra stuff like dependency warnings and build script output. can also be set with theterm.verboseconfig value <https://doc.rust-lang.org/cargo/reference/config.html>. (two v's is the move, fr fr)-q,--quietβ do NOT print cargo log messages. may also be specified with theterm.quietconfig value <https://doc.rust-lang.org/cargo/reference/config.html>. shhh π€«--color whenβ controls when colored output is used. valid values are:auto(default): automatically detect if color support is available on the terminal.always: always display colors. πnever: never display colors. π
may also be specified with the term.color config value <https://doc.rust-lang.org/cargo/reference/config.html>.
π Manifest Options π
--manifest-path pathβ path to theCargo.tomlfile. by default, Cargo searches for theCargo.tomlfile in the current directory or any parent directory. it's giving "I'll find it myself" energy. π΅οΈ--ignore-rust-versionβ ignorerust-versionspecification in packages. not me pretending that constraint doesn't exist π--lockedβ asserts that the exact same dependencies and versions are used as when the existingCargo.lockfile was originally generated. Cargo will exit with an error when either of the following scenarios arises:- the lock file is missing.
- Cargo attempted to change the lock file due to a different dependency resolution.
it may be used in environments where deterministic builds are desired, such as in CI pipelines. this is the "no surprises, periodt" flag. π
--offlineβ prevents Cargo from accessing the network for any reason. without this flag, Cargo will stop with an error if it needs to access the network and the network is not available. with this flag, Cargo will attempt to proceed without the network if possible. βοΈ
beware bestie: this may result in a different dependency resolution than online mode. Cargo will restrict itself to crates that are downloaded locally, even if there might be a newer version as indicated in the local copy of the index. see the cargo-fetch(1) command to download dependencies before going offline. π
may also be specified with the net.offline config value <https://doc.rust-lang.org/cargo/reference/config.html>.
--frozenβ equivalent to specifying both--lockedand--offline. two flags in one trench coat. π§₯β¨
π Common Options π
+toolchainβ if Cargo has been installed with rustup, and the first argument to cargo begins with+, it will be interpreted as a rustup toolchain name (such as+stableor+nightly). see the rustup documentation <https://rust-lang.github.io/rustup/overrides.html> for more information about how toolchain overrides work. π οΈ--config KEY=VALUE or PATHβ overrides a Cargo configuration value. the argument should be in TOML syntax ofKEY=VALUE, or provided as a path to an extra configuration file. this flag may be specified multiple times. see the command-line overrides section <https://doc.rust-lang.org/cargo/reference/config.html#command-line-overrides> for more information. stack 'em up π-C PATHβ changes the current working directory before executing any specified operations. this affects things like where cargo looks by default for the project manifest (Cargo.toml), as well as the directories searched for discovering.cargo/config.toml, for example. this option must appear before the command name, for examplecargo -C path/to/my-project build.
this option is only available on the nightly channel <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and requires the -Z unstable-options flag to enable (see #10098 <https://github.com/rust-lang/cargo/issues/10098>). so like, don't come crying to me on stable, okay? π
-h,--helpβ prints help information. the classic. π«Ά-Z flagβ unstable (nightly-only) flags to Cargo. runcargo -Z helpfor details. living on the edge, I see. π₯
π§ ENVIRONMENT π§
see the reference <https://doc.rust-lang.org/cargo/reference/environment-variables.html> for details on environment variables that Cargo reads. yes, cargo is nosy. it reads things. go look. π
β EXIT STATUS β
0: Cargo succeeded. π slay!!101: Cargo failed to complete. π rip
π EXAMPLES π
- Create or update the lockfile for the current package or workspace:
cargo generate-lockfile
that's it. one line. iconic. β¨
π SEE ALSO π
and that's the whole page, bestie!! this was CARGO-GENERATE-LOCKFILE(1) from the General Commands Manual β mwah, go generate that lockfile, you got this ππ¦β¨
π¦ where this page comes from
- ubuntu jammy: cargo-1.80 1.80.1+dfsg0ubuntu1~bpo0-0ubuntu0.22.04.1 Β· Apache-2.0 WITH LLVM exception
- ubuntu noble: cargo-1.80 1.80.1+dfsg0ubuntu1-0ubuntu0.24.04.01 Β· MIT OR Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms