CARGO-UPDATE(1)

πŸ“¦ version 1.89.0, in ubuntu jammy, ubuntu noble

πŸ’– 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 check cargo-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 with spec, the dependencies of spec are forced to update too. but bestie, it Cannot be used with --precise. they are not friends. 😭
  • --precise precise β€” when used with spec, 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 β€” updates spec to 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 updating Cargo.lock after you've changed version numbers in Cargo.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 the term.verbose config 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 the term.quiet config 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 the Cargo.toml file. by default, Cargo searches for the Cargo.toml file in the current directory or any parent directory. she's a detective. πŸ”
  • --ignore-rust-version β€” ignore the rust-version specification in packages. we simply do not see it. πŸ™ˆ
  • --locked β€” asserts that the exact same dependencies and versions are used as when the existing Cargo.lock file 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 --locked and --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 with Cargo.lock (e.g. --lockfile-path /tmp/temporary-lockfile/Cargo.lock). note that providing --lockfile-path will 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 to cargo begins with +, it will be interpreted as a rustup toolchain name (such as +stable or +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 of KEY=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 example cargo -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. run cargo -Z help for 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 πŸ’…

  1. Update all dependencies in the lockfile:
cargo update
  1. Update only specific dependencies:
cargo update foo bar
  1. 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