CARGO-UPDATE(1)
π NAME π
cargo-update β update dependencies as recorded in the local lock file
okay so this is a page from the General Commands Manual, and bestie, it's giving "my lockfile said what it said." β¨
πΈ SYNOPSIS πΈ
cargo update [options] spec
β¨ DESCRIPTION β¨
This command updates the dependencies in your Cargo.lock file to the latest version. And if you don't even have a Cargo.lock file yet? No worries β it'll get created for you with the latest available versions. Main character behavior honestly. π
π OPTIONS π
π« Update Options
specβ¦β Update only the packages you actually name here. This flag can be specified multiple times (go off, list them all). Peepcargo-pkgid(1)for the SPEC format.
If you do specify packages with spec, then a conservative update of the lockfile happens. Translation: only the dependency named by SPEC gets updated. Its transitive dependencies get updated only if SPEC literally cannot be updated without updating them. Every other dependency stays locked at the version it's currently recorded at. No cap. π
And if spec is not specified at all? Every single dependency gets updated. All of them. Periodt.
--recursiveβ When you use this withspec, the dependencies ofspecare forced to update as well. Cannot be used with--precise. It's giving "pick a lane." π--precise preciseβ When used withspec, this lets you name a specific 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. π₯
Now, not recommended, but you can specify a yanked version of a package (nightly only). When possible, try other non-yanked SemVer-compatible versions, or go seek help from the maintainers of the package. Like, actually ask them. π«Ά
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).
-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's lowkey perfect for updatingCargo.lockafter you've changed version numbers inCargo.toml. π--dry-runβ Displays what would be updated, but doesn't actually write the lockfile. Window shopping, but for dependencies. ποΈ
π« Display Options
-v,--verboseβ Use verbose output. May be specified twice for "very verbose" output, which includes extra output like dependency warnings and build script output. May also be specified with theterm.verboseconfig value:https://doc.rust-lang.org/cargo/reference/config.html.-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.--color whenβ Control when colored output is used. Valid values are: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-path pathβ Path to theCargo.tomlfile. By default, Cargo searches for theCargo.tomlfile in the current directory or any parent directory.--ignore-rust-versionβ Ignorerust-versionspecification in packages.--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.
--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 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. Two-for-one, iconic. π
π« 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.--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.-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).
-h,--helpβ Prints help information.-Z flagβ Unstable (nightly-only) flags to Cargo. Runcargo -Z helpfor details.
π¦ 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. π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)
and that's the whole page bestie!! π«Ά you just read CARGO-UPDATE(1), straight from the General Commands Manual β go forth and update responsibly, your lockfile is gonna eat. π
β¨
π¦ where this page comes from
- ubuntu jammy: cargo-1.79 1.79.0+dfsg1ubuntu1~bpo0-0ubuntu0.22.04.1 Β· Apache-2.0 WITH LLVM exception
- ubuntu noble: cargo-1.79 1.79.0+dfsg1ubuntu1-0ubuntu0.24.04.1 Β· 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