CARGO-GENERATE-LOCKFILE(1)
π 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 theterm.verboseconfig 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 theterm.quietconfig 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 theCargo.tomlfile. By default, Cargo searches for theCargo.tomlfile in the current directory or any parent directory. It'll go looking, don't worry. π--ignore-rust-versionβ ignore therust-versionspecification 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 existingCargo.lockfile 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--lockedand--offline. Two-for-one combo, iconic. βοΈ--lockfile-path PATHβ changes the path of the lockfile from the default (<workspace_root>/Cargo.lock) toPATH.PATHmust end withCargo.lock(e.g.--lockfile-path /tmp/temporary-lockfile/Cargo.lock). Note that providing--lockfile-pathwill ignore the existing lockfile at the default path, and instead will either use the lockfile fromPATH, or write a new lockfile into the providedPATHif it doesn't exist. This flag can be used to run most commands in read-only directories, writing the lockfile into the providedPATH.
π¨ 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+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.-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).
-h,--helpβ prints help information. When in doubt, ask for help. No shame. π«Ά-Z flagβ unstable (nightly-only) flags to Cargo. Runcargo -Z helpfor 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 β
- Create or update the lockfile for the current package or workspace:
cargo generate-lockfile
π SEE ALSO π
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
- ubuntu resolute: cargo-1.93 1.93.1+dfsg-0ubuntu6 Β· 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