CARGO-UPDATE(1)
β¨ cargo-update(1) β¨
okay bestie, welcome to the cargo-update page from the General Commands Manual (section 1, she's official π
). this is the one that goes and refreshes your deps for you. let's get into it π«Ά
π NAME π
cargo-update β Update dependencies as recorded in the local lock file
πΈ SYNOPSIS πΈ
cargo update [options] spec
π¦ DESCRIPTION π¦
So here's the vibe: this command updates your dependencies in the Cargo.lock file to the latest version. slay.
And if the Cargo.lock file doesn't even exist yet? no worries bestie, it'll get created for you with the latest available versions. it's giving β¨manifestationβ¨.
π OPTIONS π
Update Options
specβ¦β Update only the specified packages. This flag may be specified multiple times (yes queen, stack 'em π). Seecargo-pkgid(1)for the SPEC format.
Okay so here's the tea π΅: 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 cannot be updated without updating dependencies. Every other dependency stays locked at its currently recorded version. no cap.
And if spec is not specified? all dependencies are updated. go big or go home π .
--recursiveβ When used with spec, dependencies of spec are forced to update as well. Cannot be used with--precise. (they're exes, don't put them in the same room π)--preciseprecise β When used with spec, this lets you specify a specific version number to set the package to. And if the package comes from a git repository, this can be a git revision (such as a SHA hash or tag). iconic π§
Now, while it's not recommended, you can specify a yanked version of a package. When possible, try other non-yanked SemVer-compatible versions or seek help from the maintainers of the package. (like, please, bestie, ask for help first π)
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).
--breakingdirectory β Update spec to latest SemVer-breaking version.
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)
β οΈ This option is unstable and available only 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 <https://github.com/rust-lang/cargo/issues/12425> for more information.
-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. (iykyk, this one's a lifesaver π«Ά)--dry-runβ Displays what would be updated, but doesn't actually write the lockfile. it's the window shopping of cargo ποΈ
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>. (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 <https://doc.rust-lang.org/cargo/reference/config.html>. shhh π€«--colorwhen β 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>.
Manifest Options
--manifest-pathpath β Path to theCargo.tomlfile. By default, Cargo searches for theCargo.tomlfile in the current directory or any parent directory. (she'll find it, she always does π)--ignore-rust-versionβ Ignorerust-versionspecification in packages. (pretend you didn't see it π)--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 the following 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 energy for CI β¨
--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 <https://doc.rust-lang.org/cargo/reference/config.html>. airplane mode but make it cargo βοΈ
- **
--frozen** β Equivalent to specifying both--lockedand--offline`. two for one, we love a bundle deal π --lockfile-pathPATH β Changes the path of the lockfile from the default (<workspace_root>/Cargo.lock) to PATH. PATH must end withCargo.lock(e.g.--lockfile-path /tmp/temporary-lockfile/Cargo.lock). Note that providing--lockfile-pathwill ignore existing lockfile at the default path, and instead will either use the lockfile from PATH, or write a new lockfile into the provided PATH if it doesn't exist. This flag can be used to run most commands in read-only directories, writing lockfile into the provided PATH.
β οΈ 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>).
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 information about how toolchain overrides work. pick your fighter π--configKEY=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.-CPATH β 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 <https://github.com/rust-lang/cargo/issues/10098>).
-h,--helpβ Prints help information. (hi, hello, how are you π«Ά)-Zflag β Unstable (nightly-only) flags to Cargo. Runcargo -Z helpfor details. spicy mode πΆοΈ
π ENVIRONMENT π
See the reference <https://doc.rust-lang.org/cargo/reference/environment-variables.html> for details on environment variables that Cargo reads. (she reads. she's well-read. she's that girl πβ¨)
π EXIT STATUS π
0: Cargo succeeded. ate, no crumbs π101: Cargo failed to complete. it's giving tragedy π
β 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're officially fluent in cargo-update π this lil' queen lives in section 1 of the General Commands Manual, so when you need her again just pull up cargo-update(1) and she'll be right there. periodt. π
πΈπ¦
π¦ where this page comes from
- ubuntu jammy: cargo-1.82 1.82.0+dfsg0ubuntu0~jammy-0ubuntu0.22.04.1 Β· Apache-2.0 WITH LLVM exception
- ubuntu noble: cargo-1.82 1.82.0+dfsg0ubuntu0-0ubuntu0.24.04.1 Β· Apache-2.0 WITH LLVM exception
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms