CARGO-GENERATE-LOCKFILE(1)

πŸ“¦ version 1.93.1, in ubuntu resolute

πŸ’– NAME πŸ’–

cargo-generate-lockfile β€” bestie, this one generates the lockfile for a package. That's the whole job. Slay. ✨


✨ SYNOPSIS ✨

cargo generate-lockfile [options]

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so here's the tea: this command creates the Cargo.lock lockfile for your current package or workspace. That's it. That's the vibe. πŸ’…

But wait β€” if the lockfile already exists? It doesn't just shrug and leave it alone. Nope, it gets rebuilt with the latest available version of every single package. Main character energy, honestly. πŸ‘‘

Also, lowkey important: go check out cargo-update(1) too, because it can also create a Cargo.lock lockfile β€” and it comes with more options for controlling how the update behavior works. 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. 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. Silence is golden, periodt. May also be specified with the term.quiet config value (https://doc.rust-lang.org/cargo/reference/config.html).
  • --color when β€” controls when colored output is used. Valid values, bestie:
    • auto (default): automatically detect if color support is available on the terminal. Let the terminal decide, it knows itself. 🧚
    • always: always display colors. Rainbow mode unlocked. 🌈
    • never: never display colors. Monochrome moment. πŸ–€

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 the Cargo.toml file. By default, Cargo searches for the Cargo.toml file in the current directory or any parent directory. It'll go looking, don't worry. πŸ”
  • --ignore-rust-version β€” ignore the rust-version specification in packages. We're pretending we didn't see it. πŸ™ˆ
  • --publish-time yyyy-mm-ddThh:mm:ssZ β€” latest publish time allowed for registry packages (Unstable).

Heads up, this is a best-effort filter on allowed packages, and that includes these caveats:

  • packages from unsupported registries are always accepted
  • only the current yank state is respected, not the state as of --publish-time
  • precision of the publish time
  • --locked β€” asserts that the exact same dependencies and versions are used as when the existing Cargo.lock file was originally generated. Cargo will exit with an error when either of these scenarios arises:
    • The lock file is missing.
    • Cargo attempted to change the lock file due to a different dependency resolution.

Use this when you want deterministic builds, like in CI pipelines. Locked in, literally. πŸ”’

  • --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 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. If you're heading offline, peep the cargo-fetch(1) command to download dependencies before you go. ✈️

May also be specified with the net.offline config value (https://doc.rust-lang.org/cargo/reference/config.html).

  • --frozen β€” equivalent to specifying both --locked and --offline. Two-for-one combo, iconic. ❄️
  • --lockfile-path PATH β€” changes the path of the lockfile from the default (<workspace_root>/Cargo.lock) to PATH. PATH must end with Cargo.lock (e.g. --lockfile-path /tmp/temporary-lockfile/Cargo.lock). Note that providing --lockfile-path will ignore the existing lockfile at the default path, and instead will either use the lockfile from PATH, or write a new lockfile into the provided PATH if it doesn't exist. This flag can be used to run most commands in read-only directories, writing the lockfile into the provided PATH.
🚨 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 #14421 https://github.com/rust-lang/cargo/issues/14421). Not for the faint of heart, fr fr.

πŸ’« 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 +stable or +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 of KEY=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.
  • -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 example 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).
  • -h, --help β€” prints help information. When in doubt, ask for help. No shame. 🫢
  • -Z flag β€” unstable (nightly-only) flags to Cargo. Run cargo -Z help for details.

🌈 ENVIRONMENT 🌈

Cargo reads environment variables, bestie β€” see the reference (https://doc.rust-lang.org/cargo/reference/environment-variables.html) for all the details on which ones.


πŸ‘‘ EXIT STATUS πŸ‘‘

  • 0: Cargo succeeded. We ate. πŸ’…
  • 101: Cargo failed to complete. It's giving error. 😭

⭐ 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, babe β€” CARGO-GENERATE-LOCKFILE(1) from the General Commands Manual, General Commands Manual section, living its best life. Go generate that lockfile, you absolute icon. πŸŽ€ No cap, you understood all of it. πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from