CARGO-UPDATE(1)

๐Ÿ“ฆ version 1.78.0, in ubuntu jammy, ubuntu noble

๐Ÿ’– CARGO-UPDATE(1) ๐Ÿ’–

okay bestie, welcome to the General Commands Manual glow-up of cargo-update โ€” yes that's the manual name, that's the whole vibe, we're doing this ๐Ÿ’…


โœจ NAME โœจ

cargo-update โ€” Update dependencies as recorded in the local lock file


๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

cargo update [options] spec

๐ŸŒธ DESCRIPTION ๐ŸŒธ

This command will update dependencies in the Cargo.lock file to the latest version. And like โ€” if the Cargo.lock file does not exist? It gets created, with the latest available versions. iconic behavior honestly ๐Ÿซถ


๐ŸŽ€ OPTIONS ๐ŸŽ€

๐Ÿ’œ Update Options

  • specโ€ฆ โ€” Update only the specified packages. This flag may be specified multiple times. See cargo-pkgid(1) for the SPEC format.

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 literally cannot be updated without updating dependencies. All other dependencies stay locked at their currently recorded versions. no cap ๐Ÿ”’

If spec is not specified, all dependencies are updated. all of them. the whole squad.

  • --recursive โ€” When used with spec, dependencies of spec are forced to update as well. Cannot be used with --precise. (they're mutually exclusive bestie, pick one ๐Ÿ’€)
  • --precise precise โ€” When used with spec, allows you to specify a specific version number to set the package to. If the package comes from a git repository, this can be a git revision (such as a SHA hash or tag).

While not recommended, you can specify a yanked version of a package (nightly only). When possible, try other non-yanked SemVer-compatible versions or seek help from the maintainers of the package.

okay so this is the "I know what I'm doing" flag. yanked versions are yanked for a reason bestie, maybe ask the maintainers first ๐Ÿ™ˆ
  • -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 updating Cargo.lock after you've changed version numbers in Cargo.toml. perfect lil refresh moment โœจ
  • --dry-run โ€” Displays what would be updated, but doesn't actually write the lockfile. window shopping only, no commitment ๐Ÿ›๏ธ

๐ŸŒˆ 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 the term.verbose config value at 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 the term.quiet config value at https://doc.rust-lang.org/cargo/reference/config.html. shhhh ๐Ÿคซ
  • --color when โ€” 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 at https://doc.rust-lang.org/cargo/reference/config.html. we love a little color coordination ๐ŸŽจ

๐Ÿงš 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. it'll go looking for it, don't worry ๐Ÿ‘€
  • --frozen, --locked โ€” Either of these flags requires that the Cargo.lock file is up-to-date. If the lock file is missing, or it needs to be updated, Cargo will exit with an error. The --frozen flag also prevents Cargo from attempting to access the network to determine if it is out-of-date.

These may be used in environments where you want to assert that the Cargo.lock file is up-to-date (such as a CI build) or want to avoid network access.

these are your "do NOT touch anything, I'm watching you" flags. great for CI, great for planes, terrible for surprises ๐Ÿšจ
  • --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 at https://doc.rust-lang.org/cargo/reference/config.html.

lowkey different resolution means different vibes. grab your crates before you go off-grid fr fr โœˆ๏ธ

โญ 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 at https://rust-lang.github.io/rustup/overrides.html for more information about how toolchain overrides work. toolchain switching is such main character energy ๐Ÿ‘‘
  • --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 at https://doc.rust-lang.org/cargo/reference/config.html#command-line-overrides for more information. stackable, like a good outfit ๐Ÿ’…
  • -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 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).

nightly-only bestie, don't come crying to me on stable ๐Ÿ˜ญ
  • -h, --help โ€” Prints help information. our lord and savior honestly ๐Ÿ™
  • -Z flag โ€” Unstable (nightly-only) flags to Cargo. Run cargo -Z help for details. the forbidden knowledge section ๐Ÿ”ฎ

๐ŸŒฑ 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. we ate. ๐Ÿ”ฅ
  • 101: Cargo failed to complete. it's giving tragic ๐Ÿ˜ญ

๐Ÿ“ 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)


that's the whole page bestie, go forth and update responsibly ๐Ÿ’–โœจ

CARGO-UPDATE(1) โ€” yeah that's the source/version and date tag, the lil signature at the bottom of the page, consider it your receipt ๐Ÿงพ๐Ÿซถ

๐Ÿ“ฆ where this page comes from