CARGO-UPDATE(1)
๐ CARGO-UPDATE(1) ๐
okay bestie, welcome to the General Commands Manual glow-up of cargo-update โ yes that's the manual name, that's the whole vibe, we're doing this ๐
โจ NAME โจ
cargo-update โ Update dependencies as recorded in the local lock file
๐ฆ SYNOPSIS ๐ฆ
cargo update [options] spec
๐ธ DESCRIPTION ๐ธ
This command will update dependencies in the Cargo.lock file to the latest version. And like โ if the Cargo.lock file does not exist? It gets created, with the latest available versions. iconic behavior honestly ๐ซถ
๐ OPTIONS ๐
๐ Update Options
specโฆโ Update only the specified packages. This flag may be specified multiple times. Seecargo-pkgid(1)for the SPEC format.
If packages are specified with spec, then a conservative update of the lockfile will be performed. Translation: only the dependency specified by SPEC will be updated. Its transitive dependencies will be updated only if SPEC literally cannot be updated without updating dependencies. All other dependencies stay locked at their currently recorded versions. no cap ๐
If spec is not specified, all dependencies are updated. all of them. the whole squad.
--recursiveโ When used withspec, dependencies ofspecare forced to update as well. Cannot be used with--precise. (they're mutually exclusive bestie, pick one ๐)--precise preciseโ When used withspec, allows you to specify a specific version number to set the package to. If the package comes from a git repository, this can be a git revision (such as a SHA hash or tag).
While not recommended, you can specify a yanked version of a package (nightly only). When possible, try other non-yanked SemVer-compatible versions or seek help from the maintainers of the package.
okay so this is the "I know what I'm doing" flag. yanked versions are yanked for a reason bestie, maybe ask the maintainers first ๐
-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 option is useful for updatingCargo.lockafter you've changed version numbers inCargo.toml. perfect lil refresh moment โจ--dry-runโ Displays what would be updated, but doesn't actually write the lockfile. window shopping only, no commitment ๐๏ธ
๐ 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 athttps://doc.rust-lang.org/cargo/reference/config.html. double it and give it to the next person ๐ข-q,--quietโ Do not print cargo log messages. May also be specified with theterm.quietconfig value athttps://doc.rust-lang.org/cargo/reference/config.html. shhhh ๐คซ--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 at https://doc.rust-lang.org/cargo/reference/config.html. we love a little color coordination ๐จ
๐ง 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 for it, don't worry ๐--frozen,--lockedโ Either of these flags requires that theCargo.lockfile is up-to-date. If the lock file is missing, or it needs to be updated, Cargo will exit with an error. The--frozenflag also prevents Cargo from attempting to access the network to determine if it is out-of-date.
These may be used in environments where you want to assert that the Cargo.lock file is up-to-date (such as a CI build) or want to avoid network access.
these are your "do NOT touch anything, I'm watching you" flags. great for CI, great for planes, terrible for surprises ๐จ
--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.
Beware that 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 at https://doc.rust-lang.org/cargo/reference/config.html.
lowkey different resolution means different vibes. grab your crates before you go off-grid fr fr โ๏ธ
โญ 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 athttps://rust-lang.github.io/rustup/overrides.htmlfor more information about how toolchain overrides work. toolchain switching is such main character energy ๐--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. stackable, like a good outfit ๐-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 at 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).
nightly-only bestie, don't come crying to me on stable ๐ญ
-h,--helpโ Prints help information. our lord and savior honestly ๐-Z flagโ Unstable (nightly-only) flags to Cargo. Runcargo -Z helpfor details. the forbidden knowledge section ๐ฎ
๐ฑ ENVIRONMENT ๐ฑ
See the reference at https://doc.rust-lang.org/cargo/reference/environment-variables.html for details on environment variables that Cargo reads.
๐ EXIT STATUS ๐
0: Cargo succeeded. we ate. ๐ฅ101: Cargo failed to complete. it's giving tragic ๐ญ
๐ 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)
that's the whole page bestie, go forth and update responsibly ๐โจ
CARGO-UPDATE(1) โ yeah that's the source/version and date tag, the lil signature at the bottom of the page, consider it your receipt ๐งพ๐ซถ
๐ฆ where this page comes from
- ubuntu jammy: cargo-1.78 1.78.0+dfsg1ubuntu1~bpo0-0ubuntu0.22.04.1 ยท Apache-2.0 WITH LLVM exception
- ubuntu noble: cargo-1.78 1.78.0+dfsg1ubuntu1-0ubuntu0.24.04.2 ยท 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