CARGO-UPDATE(1)
โจ cargo-update โ the glow-up your Cargo.lock deserves โจ
okay bestie, welcome to the cargo-update(1) page from the General Commands Manual ๐ this is the little command that refreshes your dependencies, and honestly? it's giving main character energy. let's get into it ๐ซถ
๐ธ NAME ๐ธ
cargo-update โ Update dependencies as recorded in the local lock file
like, it updates your deps. that's the vibe. periodt. ๐
๐ฆ SYNOPSIS ๐ฆ
cargo update [options] spec
short, sweet, iconic. no cap.
๐ DESCRIPTION ๐
so basically, this command updates the dependencies in your Cargo.lock file to the latest version. that's the whole mission, that's the whole plot ๐
and if the Cargo.lock file doesn't exist yet? no worries bestie โ Cargo will just create it for you, already filled with the latest available versions. it's literally born ready. โจ
๐ OPTIONS ๐
๐ Update Options ๐
specโฆโ Update only the packages you name here. This flag can be specified multiple times (you can stack it, you're allowed ๐ ). Peepcargo-pkgid(1)for the SPEC format, iykyk.
If you do pass packages with spec, then a conservative update of the lockfile happens. What does that mean? Only the dependency named by SPEC gets updated. Its transitive dependencies only get updated if SPEC literally cannot be updated without updating them. Everything else stays locked at the versions currently recorded. so basically: minimal chaos, maximum control ๐
And if you don't specify spec? Then all dependencies get updated. go big or go home. ๐ฅ
--recursiveโ When used withspec, the dependencies ofspecare forced to update as well. Cannot be used with--precise. pick a lane bestie ๐ญ--precise preciseโ When used withspec, this lets you specify an exact version number to set the package to. And if the package comes from a git repository, this can be a git revision (like a SHA hash or a tag). very specific, very demure โจ
โ ๏ธ While not recommended, you can specify a yanked version of a package. When possible, try other non-yanked SemVer-compatible versions, or go ask the package maintainers for help. yanked versions are lowkey a red flag, bestie ๐
A compatible pre-release version can also be specified even when the version requirement in Cargo.toml doesn't contain any pre-release identifier โ but heads up, that's nightly only. ๐
-w,--workspaceโ Attempt to update only packages defined in the workspace. Other packages are updated only if they don't already exist in the lockfile. This one is super useful for updatingCargo.lockafter you've changed version numbers inCargo.toml. chef's kiss ๐ฉโ๐ณ๐--dry-runโ Displays what would be updated, but doesn't actually write the lockfile. it's the window-shopping of dependency management ๐๏ธ
๐ Display Options ๐
-v,--verboseโ Use verbose output. May be specified 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. the more-vyou add, the more it yaps ๐ฃ๏ธ-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. shhh, it's napping ๐ด--color whenโ Control 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. aesthetics are configurable, as they 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's a little detective ๐--ignore-rust-versionโ Ignorerust-versionspecification in packages. who even needs it, right? (jk, it's there for a reason, but this flag says "not today") ๐--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.
It may be used in environments where deterministic builds are desired, such as 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 is not available. With this flag, Cargo will attempt to proceed without the network if possible. airplane mode but for crates โ๏ธ
โ ๏ธ 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--lockedand--offline. it's the combo meal ๐๐
โญ 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 athttps://rust-lang.github.io/rustup/overrides.htmlfor more information about how toolchain overrides work. yes queen, pick your toolchain ๐--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 athttps://doc.rust-lang.org/cargo/reference/config.html#command-line-overridesfor more information. stack those configs, girl ๐-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-optionsflag to enable (see #10098 athttps://github.com/rust-lang/cargo/issues/10098). nightly girlies only ๐
-h,--helpโ Prints help information. when in doubt, ask for help, bestie ๐ซถ-Z flagโ Unstable (nightly-only) flags to Cargo. Runcargo -Z helpfor details. the secret menu ๐ฎ
๐ธ ENVIRONMENT ๐ธ
See the reference at https://doc.rust-lang.org/cargo/reference/environment-variables.html for details on environment variables that Cargo reads. it reads env vars, it has feelings, it's a whole person ๐
๐ฆ EXIT STATUS ๐ฆ
0: Cargo succeeded. ๐101: Cargo failed to complete. ๐ญ
those are the only two moods fr fr.
โจ 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)
and that's the whole page bestie, you ate that ๐ thanks for reading the cargo-update(1) page from the General Commands Manual โ now go update those deps and slay ๐ฅ๐ฆ๐
๐ฆ where this page comes from
- ubuntu jammy: cargo-1.80 1.80.1+dfsg0ubuntu1~bpo0-0ubuntu0.22.04.1 ยท Apache-2.0 WITH LLVM exception
- ubuntu noble: cargo-1.80 1.80.1+dfsg0ubuntu1-0ubuntu0.24.04.01 ยท 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