CARGO-UPDATE(1)
π cargo-update(1) β the manual page, but make it slay π
okay bestie, sit down, hydrate, because we're about to talk about updating your dependencies as recorded in the local lock file. that's the whole vibe. it's cargo-update from the General Commands Manual and she is iconic. π¦
β¨ SYNOPSIS β¨
cargo update [options] spec
short. punchy. main character energy. π
πΈ DESCRIPTION πΈ
so here's the tea: this command updates the dependencies in your Cargo.lock file to the latest version. that's it, that's the job. π
and if the Cargo.lock file doesn't even exist yet? no worries bestie, it'll be created</> with the latest available versions. it's giving "i'll make it work". β¨
π OPTIONS π
π« Update Options π«
specβ¦β update only the packages you name. you can drop this in multiple times, no cap. and bestie, if you wanna know the SPEC format, go checkcargo-pkgid(1). π
so like, if you do specify packages with spec, then a conservative update of the lockfile happens. meaning: only the dependency you named in SPEC gets updated. its transitive dependencies? they only get updated if SPEC literally cannot be updated without touching them. every other dependency stays locked at the versions it currently has recorded. loyalty. π«Ά
and if spec is not specified? then all the dependencies get updated. go off. π₯
--recursiveβ when you use this withspec, the dependencies ofspecare forced to update too. but bestie, it Cannot be used with--precise. they are not friends. π--precise preciseβ when used withspec, this lets you say exactly which 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. π§
ngl, it's not recommended, but you can specify a yanked version of a package. when you can, please try other non-yanked SemVer-compatible versions, or go ask the maintainers of the package for help. π₯Ί
also! a compatible pre-release version can be specified even when the version requirement in Cargo.toml doesn't contain any pre-release identifier. (nightly only, iykyk) π
--breaking directoryβ updatesspecto the 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)
β οΈ heads up bestie: 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β 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 genuinely useful for updatingCargo.lockafter you've changed version numbers inCargo.toml. π--dry-runβ displays what would be updated, but doesn't actually write the lockfile. it's giving window shopping. ποΈ
π Display Options π
-v,--verboseβ verbose output, please and thank you. you can specify it 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. silence, but make it chic. may also be specified with theterm.quietconfig value <https://doc.rust-lang.org/cargo/reference/config.html>. π€«--color whenβ controls 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. she's a detective. π--ignore-rust-versionβ ignore therust-versionspecification in packages. we simply do not 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 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, we love a bundle. π--lockfile-path PATHβ 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 the 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 the 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. βοΈ--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 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 <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. bestie behaviour. π«Ά-Z flagβ unstable (nightly-only) flags to Cargo. runcargo -Z helpfor details. π
π± ENVIRONMENT π±
see the reference <https://doc.rust-lang.org/cargo/reference/environment-variables.html> for details on environment variables that Cargo reads. that's the whole section, she's lowkey mysterious like that. πΏ
β 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, no notes, ate and left no crumbs ππ
okay bye ily, this was CARGO-UPDATE(1) from the General Commands Manual, and consider this your cute little sign-off. now go update your lockfile. periodt. πβ¨
π¦ where this page comes from
- ubuntu jammy: cargo-1.89 1.89.0+dfsg~24.04-0ubuntu0.22.04.2 Β· Apache-2.0 WITH LLVM exception
- ubuntu noble: cargo-1.89 1.89.0+dfsg~24.04-0ubuntu0.24.04.2 Β· 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