CARGO-UPDATE(1)
β¨ CARGO-UPDATE(1) β¨
okay so welcome to the cargo-update page, bestie π this is straight out of the General Commands Manual and it's literally the glow-up command for your dependency list. no cap.
π NAME π
cargo-update β updates dependencies exactly as they're recorded in the local lock file π¦
πΈ SYNOPSIS πΈ
cargo update [options] spec
π DESCRIPTION π
so here's the vibe: this command updates the dependencies inside your Cargo.lock file up to the latest version. that's the whole main character moment. π
and if Cargo.lock doesn't even exist yet? not a problem β it'll be created for you, loaded up with the latest available versions. iconic behavior honestly π
β¨ OPTIONS β¨
π οΈ Update Options
specβ¦β only update the packages you name here, and yes you can drop this flag multiple times for multiple packages. the SPEC format lives over incargo-pkgid(1), go peek π«Ά
if you do pass packages with spec, you get a conservative update of the lockfile. translation: only the dependency you named in SPEC gets updated. its transitive dependencies will only move if SPEC literally cannot be updated without updating them. everything else stays locked at the versions currently recorded. no sneaky updates, we're being respectful π
if spec is not specified at all, then all dependencies get updated. full send π
--recursiveβ when you use it withspec, the dependencies ofspecare forced to update too. cannot be used with--precise. pick a lane bestie π--preciseprecise β when you use it withspec, this lets you name a specific version number to pin 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 β¨
ngl, while it's not recommended, you can specify a yanked version of a package. when you can avoid it though, try other non-yanked SemVer-compatible versions, or go ask the package maintainers for help. yanked is yanked for a reason π©
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). okayyy π
--breakingdirectory β 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: this option is unstable and available only on the nightly channel <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and it requires the -Z unstable-options flag to enable. see <https://github.com/rust-lang/cargo/issues/12425> for more information. so like, don't try this on stable and then act surprised π
-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 lowkey a lifesaver for updatingCargo.lockafter you've changed version numbers inCargo.toml. π§--dry-runβ shows you what would be updated, but doesn't actually write the lockfile. window shopping, no checkout ποΈ
π Display Options
-v,--verboseβ use verbose output. and yes, you can specify it twice for "very verbose" output, which includes extra stuff like dependency warnings and build script output. double the tea ββ 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 is golden, periodt π€« may also be specified with theterm.quietconfig value <https://doc.rust-lang.org/cargo/reference/config.html>.--colorwhen β 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-pathpath β path to theCargo.tomlfile. by default, Cargo searches forCargo.tomlin the current directory or any parent directory. it will find it, it always finds it π--ignore-rust-versionβ ignore therust-versionspecification in packages. we're ignoring that, bestie π--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 comes up:- 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. very much a "trust the process" flag π«Ά
--offlineβ prevents Cargo from accessing the network for any reason. without this flag, Cargo stops with an error if it needs the network and the network isn't available. with this flag, Cargo will attempt to proceed without the network if it can. airplane mode βοΈ
beware bestie, this may result in a 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. plan ahead π
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 combo deal π
π Common Options
+toolchainβ if Cargo has been installed with rustup, and the first argument tocargobegins with+, it'll be interpreted as a rustup toolchain name (like+stableor+nightly). see the rustup documentation <https://rust-lang.github.io/rustup/overrides.html> for more on how toolchain overrides work. β¨--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. stack 'em up π-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, babes π
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. when in doubt, ask for help, that's self care π-Zflag β unstable (nightly-only) flags to Cargo. runcargo -Z helpfor details. the forbidden knowledge section π―οΈ
π ENVIRONMENT π
see the reference <https://doc.rust-lang.org/cargo/reference/environment-variables.html> for details on environment variables that Cargo reads. it reads them, it's nosy, we respect it π¦
π¦ EXIT STATUS π¦
0: Cargo succeeded. slay π101: Cargo failed to complete. π it's giving "we don't talk about it"
π 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 π this one lives as CARGO-UPDATE(1) under the General Commands Manual β go update something and feel the main character energy, fr fr πβ¨π¦
π¦ where this page comes from
- ubuntu stonking: cargo-1.97 1.97.1+dfsg-0ubuntu1 Β· 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