CARGO-GENERATE-LOCKFILE(1)

๐Ÿ’… NAME ๐Ÿ’…

cargo-generate-lockfile โ€” bestie, this one generates the lockfile for a package. That's it. That's the job. ๐ŸŽ€


โœจ SYNOPSIS โœจ

cargo generate-lockfile [options]

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

okay so picture this: you run this command and it creates the Cargo.lock lockfile for whatever package or workspace you're standing in. ๐Ÿ’–

And if the lockfile is already there? Not me being lazy โ€” it gets rebuilt with the latest available version of every package. Glow up, lockfile edition. โœจ

Also also also โ€” go look at cargo-update(1). That one can make a Cargo.lock lockfile too, and it's got more options for controlling update behavior. So if you need finer control, that's your girl. ๐Ÿ‘‘


๐ŸŒˆ OPTIONS ๐ŸŒˆ

๐Ÿ’– Display Options ๐Ÿ’–

  • -v, --verbose โ€” verbose output, periodt. Say it twice and you get "very verbose" output, which is giving 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, iconic, no notes. ๐Ÿซถ Can also be set with the term.quiet config value: https://doc.rust-lang.org/cargo/reference/config.html.
  • --color when โ€” controls when colored output gets used. Valid values, bestie:
    • auto (default): automatically detect if color support is available on the terminal. lowkey smart of it.
    • always: always display colors. ๐ŸŒˆ slay.
    • never: never display colors.

Can also be set with the term.color config value: https://doc.rust-lang.org/cargo/reference/config.html.

๐ŸŒธ Manifest Options ๐ŸŒธ

  • --manifest-path path โ€” the path to the Cargo.toml file. By default, Cargo goes hunting for Cargo.toml in the current directory or any parent directory. it's giving detective energy. ๐Ÿ”
  • --ignore-rust-version โ€” ignore the rust-version specification in packages. pretend you didn't see it. ๐Ÿ™ˆ
  • --publish-time yyyy-mm-ddThh:mm:ssZ โ€” latest publish time allowed for registry packages (Unstable). โš ๏ธ

This is a best-effort filter on allowed packages, including:

  • 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.

It may be used in environments where deterministic builds are desired, such as in CI pipelines. main character CI behavior fr fr.

  • --offline โ€” prevents Cargo from accessing the network for any reason. Without this flag, Cargo stops with an error if it needs the network and the network isn't there. 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.

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 at the same time. two-for-one, we love a bundle. ๐ŸŽ€

๐Ÿ’œ Common Options ๐Ÿ’œ

  • +toolchain โ€” if Cargo has been installed with rustup, and the first argument to cargo begins with +, it gets interpreted as a rustup toolchain name (like +stable or +nightly). See the rustup documentation for more info on how toolchain overrides work: https://rust-lang.github.io/rustup/overrides.html.
  • --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 for more: https://doc.rust-lang.org/cargo/reference/config.html#command-line-overrides.
  • -C PATH โ€” changes the current working directory before executing any specified operations. This affects stuff like where cargo looks by default for the project manifest (Cargo.toml), and also 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 and requires the -Z unstable-options flag to enable (see #10098: https://github.com/rust-lang/cargo/issues/10098). ๐Ÿงšโœจ
  • -h, --help โ€” prints help information. our hero. ๐Ÿซถ
  • -Z flag โ€” unstable (nightly-only) flags to Cargo. Run cargo -Z help for details. iykyk. ๐Ÿ‘‘

๐ŸŒฑ ENVIRONMENT ๐ŸŒฑ

See the reference for the details on environment variables that Cargo reads: https://doc.rust-lang.org/cargo/reference/environment-variables.html


โญ EXIT STATUS โญ

  • 0: Cargo succeeded. ๐ŸŽ‰
  • 101: Cargo failed to complete. ๐Ÿ’€

๐Ÿ“ 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, no cap ๐Ÿ’– this was CARGO-GENERATE-LOCKFILE(1) from the General Commands Manual, signing off โ€” go forth and lock those files, you absolute icon ๐ŸŽ€โœจ๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from