CARGO-UPDATE(1)
๐ CARGO-UPDATE(1) ๐
okay bestie, welcome to the cargo-update page โ it's a general commands manual page, and it's literally the glow-up button for your lockfile ๐
โจ NAME โจ
cargo-update โ update dependencies as recorded in the local lock file ๐ฆ
โจ SYNOPSIS โจ
cargo update [options] spec
โจ DESCRIPTION โจ
So this command updates the dependencies in the Cargo.lock file to the latest version. that's it, that's the whole vibe. ๐ฅ
And if the Cargo.lock file doesn't even exist yet? no worries, it gets created with the latest available versions. it's giving "manifesting your lockfile into existence" โจ
โจ OPTIONS โจ
๐ Update Options
specโฆโ updates only the packages you name. you can drop this flag multiple times if you're feeling extra. the SPEC format lives over incargo-pkgid(1), go peek at that for the deets.
Here's the tea tho: if you specify packages with spec, then a conservative update of the lockfile happens. translation? only the dependency named by SPEC gets updated. its transitive dependencies will only move if SPEC literally cannot be updated without moving them. everything else stays locked at the versions currently recorded. no chaotic cascade, we're being mindful ๐ง
If spec is not specified, then ALL dependencies are updated. all of them. the whole squad. ๐
--recursiveโ when you use this with spec, the dependencies of spec are forced to update too. but bestie, it cannot be used with--precise. they do not sit together, periodt. ๐--precise preciseโ when used with spec, this lets you pin the package to a specific version number. and if the package comes from a git repository, precise can be a git revision โ like a SHA hash or a tag. yes, really. ๐
Now, while it is not recommended, you can specify a yanked version of a package. if you can avoid it though, try other non-yanked SemVer-compatible versions, or go ask the package maintainers for help. ๐ซถ
A compatible pre-release version can also be specified even when the version requirement in Cargo.toml doesn't contain any pre-release identifier โ nightly only tho. ๐
--breakingโ updates spec to the highest SemVer-breaking version. yes, we're breaking things on purpose. version requirements will be modified to allow this update. ๐ญ
This only applies to dependencies when:
- The package is a dependency of a workspace member
- The dependency is not renamed
- A SemVer-incompatible version is available
- The "SemVer operator" is used (
^, which is the default)
๐จ heads up: this option is unstable and available only on the nightly channel (https://doc.rust-lang.org/book/appendix-07-nightly-rust.html), and it requires the -Z unstable-options flag to enable. See https://github.com/rust-lang/cargo/issues/12425 for more info.
-w,--workspaceโ attempts to update only the packages defined in the workspace. other packages get updated only if they don't already exist in the lockfile. this one is so useful for updatingCargo.lockafter you've changed version numbers inCargo.toml. chef's kiss ๐ฉโ๐ณ๐--dry-runโ shows you what would be updated, but doesn't actually write the lockfile. window shopping only, no purchasing. ๐๏ธ
๐ Display Options
-v,--verboseโ verbose output. you can specify it twice for "very verbose" output, which includes extra output such as dependency warnings and build script output. may also be specified with theterm.verboseconfig value (https://doc.rust-lang.org/cargo/reference/config.html). she's chatty and we love her ๐ฃ๏ธ-q,--quietโ do not print cargo log messages. may also be specified with theterm.quietconfig value (https://doc.rust-lang.org/cargo/reference/config.html). silent mode, main character mystery energy ๐คซ--color whenโ controls when colored output is used. valid values:auto(default): automatically detect if color support is available on the terminal.always: always display colors.never: never display colors.
May also be specified with the term.color config value (https://doc.rust-lang.org/cargo/reference/config.html). aesthetic is configurable, as it should be ๐ธ
๐ 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 goes looking for its home ๐--ignore-rust-versionโ ignore therust-versionspecification in packages. ignoring the rules, iconic behaviour ๐--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.
You'd use this in environments where deterministic builds are desired, such as CI pipelines. no surprises allowed, we're locked in fr fr ๐
--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 is not available. with this flag, Cargo will attempt to proceed without the network if possible. airplane mode, but for builds โ๏ธ
โ ๏ธ beware: 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--lockedand--offline. two-for-one deal, we love a bundle ๐
๐ Common Options
+toolchainโ if Cargo has been installed with rustup, and the first argument tocargobegins 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 info about how toolchain overrides work. pick your fighter โ๏ธ--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 info. stack 'em up ๐ฅ-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. order matters bestie, don't fight it ๐
๐ 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 at https://github.com/rust-lang/cargo/issues/10098).
-h,--helpโ prints help information. when in doubt, ask for help, that's growth ๐ฑ-Z flagโ unstable (nightly-only) flags to Cargo. runcargo -Z helpfor details. the forbidden zone, enter with caution ๐ฎ
โจ ENVIRONMENT โจ
See the reference (https://doc.rust-lang.org/cargo/reference/environment-variables.html) for details on environment variables that Cargo reads. ๐
โจ EXIT STATUS โจ
0: Cargo succeeded. ๐101: Cargo failed to complete. ๐ญ
โจ EXAMPLES โจ
- Update all dependencies in the lockfile:
cargo update
- Update only specific dependencies:
cargo update foo bar
- Set a specific dependency to a specific version:
cargo update foo --precise 1.2.3
โจ SEE ALSO โจ
cargo(1), cargo-generate-lockfile(1) ๐ซถ
aaaand that's the whole page bestie!! this was CARGO-UPDATE(1) from the General Commands Manual โ the footer just says CARGO-UPDATE(1) again, no extra version or date tea in there. go update those deps, slay, and remember: conservative updates only when you say so ๐โจ๐
๐ฆ where this page comes from
- centos-stream 10: cargo 1.99.1-1.el10 ยท (Apache-2.0 OR MIT) AND (Artistic-2.0 AND BSD-3-Clause AND ISC AND MIT AND MPL-2.0 AND Unicode-3.0)
- centos-stream 9: cargo 1.99.1-1.el9 ยท (Apache-2.0 OR MIT) AND (Artistic-2.0 AND BSD-3-Clause AND ISC AND MIT AND MPL-2.0 AND Unicode-3.0)
- fedora 43: cargo 1.99.0-1.fc43
- fedora 43: cargo 1.99.1-2.fc43 ยท (Apache-2.0 OR MIT) AND (Artistic-2.0 AND BSD-3-Clause AND ISC AND MIT AND MPL-2.0 AND Unicode-3.0)
- fedora 44: cargo 1.99.0-1.fc44
- fedora 44: cargo 1.99.1-2.fc44 ยท (Apache-2.0 OR MIT) AND (Artistic-2.0 AND BSD-3-Clause AND ISC AND MIT AND MPL-2.0 AND Unicode-3.0)
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms