CARGO-GENERATE-LOCKFILE(1)
β¨ cargo-generate-lockfile β¨
okay bestie, buckle up π this is a page from the General Commands Manual, and it's all about cargo-generate-lockfile.
π 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 whatever package or workspace you're standing in rn. and if the lockfile is already there? no worries, it just gets rebuilt with the latest available version of every single package. it's giving glow-up, honestly β¨
also, lowkey important: go look at cargo-update(1) too, because that one can also create a Cargo.lock lockfile and it's got way more options for controlling how the update behavior goes down. iykyk π
π OPTIONS π
β¨ Display Options β¨
-v,--verboseβ use verbose output. you can stack it twice for "very verbose" output, which unlocks the extra lore: dependency warnings and build script output. you can also set this with theterm.verboseconfig value <https://doc.rust-lang.org/cargo/reference/config.html>.-q,--quietβ do not print cargo log messages. also settable via theterm.quietconfig value <https://doc.rust-lang.org/cargo/reference/config.html>.--colorwhen β controls when colored output gets used. valid values, periodt:auto(default): automatically detect if color support is available on the terminal. she checks first πalways: always display colors. rainbow mode, no cap πnever: never display colors. monochrome era, respectfully π€
you can also set this with the term.color config value <https://doc.rust-lang.org/cargo/reference/config.html>.
π§ Manifest Options π§
--manifest-pathpath β path to theCargo.tomlfile. by default, Cargo goes looking for theCargo.tomlfile in the current directory or any parent directory. it will literally climb the whole tree for you π«Ά--frozen,--lockedβ either one of these flags requires that theCargo.lockfile is up-to-date. if the lock file is missing, or it needs an update, Cargo will exit with an error. and the--frozenflag also stops Cargo from even attempting to access the network to figure out if it's out-of-date. so:
these are the flags for environments where you want to assert that the Cargo.lock file is up-to-date (like a CI build, bestie) or where you want to avoid network access entirely.
--offlineβ prevents Cargo from accessing the network for any reason. without this flag, Cargo will stop with an error if it needs the network and the network isn't available. with this flag, Cargo will attempt to proceed without the network if possible.
β οΈ beware bestie: this may result in 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. plan ahead, queen π
you can also set this with the net.offline config value <https://doc.rust-lang.org/cargo/reference/config.html>.
π Common Options π
+toolchainβ if Cargo was installed with rustup, and the first argument tocargobegins with+, it gets interpreted as a rustup toolchain name (such as+stableor+nightly). see the rustup documentation <https://rust-lang.github.io/rustup/overrides.html> for more info on how toolchain overrides work.--configKEY=VALUE or PATH β overrides a Cargo configuration value. the argument should be in TOML syntax ofKEY=VALUE, or given 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.-CPATH β 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), plus the directories searched for discovering.cargo/config.toml, for example. this option must appear before the command name, likecargo -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>). nightly girlies only, sorry π
-h,--helpβ prints help information. the classic π«Ά-Zflag β unstable (nightly-only) flags to Cargo. runcargo -Z helpfor details.
π ENVIRONMENT π
see the reference <https://doc.rust-lang.org/cargo/reference/environment-variables.html> for details on environment variables that Cargo reads. yes, she reads them. she's nosy like that π
β EXIT STATUS β
0: Cargo succeeded. slay π101: Cargo failed to complete. we don't talk about it π
π EXAMPLES π
- Create or update the lockfile for the current package or workspace:
cargo generate-lockfile
π SEE ALSO π
and that's the whole page, bestie!! this was cargo-generate-lockfile(1) from the General Commands Manual β go forth and lock those files πβ¨π
π¦ where this page comes from
- ubuntu jammy: cargo-1.78 1.78.0+dfsg1ubuntu1~bpo0-0ubuntu0.22.04.1 Β· Apache-2.0 WITH LLVM exception
- ubuntu noble: cargo-1.78 1.78.0+dfsg1ubuntu1-0ubuntu0.24.04.2 Β· 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