CARGO-GENERATE-LOCKFILE(1)

πŸ“¦ version 1.77.2, in ubuntu jammy, ubuntu noble

✨ 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 the term.verbose config value <https://doc.rust-lang.org/cargo/reference/config.html>.
  • -q, --quiet β€” do not print cargo log messages. also settable via the term.quiet config value <https://doc.rust-lang.org/cargo/reference/config.html>.
  • --color when β€” 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-path path β€” path to the Cargo.toml file. by default, Cargo goes looking for the Cargo.toml file 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 the Cargo.lock file is up-to-date. if the lock file is missing, or it needs an update, Cargo will exit with an error. and the --frozen flag 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 to cargo begins with +, it gets interpreted as a rustup toolchain name (such as +stable or +nightly). see the rustup documentation <https://rust-lang.github.io/rustup/overrides.html> for more info on how toolchain overrides work.
  • --config KEY=VALUE or PATH β€” overrides a Cargo configuration value. the argument should be in TOML syntax of KEY=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.
  • -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), plus the directories searched for discovering .cargo/config.toml, for example. this option must appear before the command name, like cargo -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 🫢
  • -Z flag β€” unstable (nightly-only) flags to Cargo. run cargo -Z help for 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 πŸ“

  1. Create or update the lockfile for the current package or workspace:
cargo generate-lockfile

πŸ‘‘ SEE ALSO πŸ‘‘

cargo(1), cargo-update(1)


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