CARGO-UPDATE(1)

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

πŸ’… NAME πŸ’…

okay so bestie, this is cargo-update β€” it updates your dependencies to whatever's recorded in the local lock file. no cap, that's the whole vibe. ✨


🌸 SYNOPSIS 🌸


---

# πŸ¦‹ DESCRIPTION πŸ¦‹

so basically this command updates the dependencies in your `Cargo.lock` file to their latest versions. and if there's no `Cargo.lock` file yet? it literally just creates one for you with the latest available versions. main character energy fr. πŸ‘‘

---

# ✨ OPTIONS ✨

## πŸŽ€ Update Options πŸŽ€

- **`spec…`** β€” updates *only* the packages you name. you can drop this flag multiple times if you want, go off. check `cargo-pkgid(1)` for the SPEC format, iykyk.

  if you do pass `spec`, you get a **conservative update** of the lockfile. that means only the dependency you named in SPEC gets updated. its transitive dependencies only get updated if SPEC literally *cannot* be updated without touching them. everything else stays locked at the versions it already has. no sneaky changes. πŸ™ˆ

  and if you don't specify `spec` at all? every single dependency gets updated. all of them. periodt.

- **`--recursive`** β€” when you use it with `spec`, the dependencies of `spec` are forced to update too. cannot be used with `--precise`, so pick a lane. πŸ’…

- **`--precise`** *precise* β€” when used with `spec`, this lets you set a package to a **specific version number**. if the package comes from a git repository, this can be a git revision β€” like a SHA hash or a tag. cute and precise, as the name says. 🎯

  > ngl, you *can* specify a **yanked** version of a package, but it's not recommended. when possible, try other non-yanked SemVer-compatible versions first, or go ask the maintainers of the package for help. don't be messy. 😭

  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**, bestie. ⭐

- **`--breaking`** *directory* β€” updates `spec` to the latest SemVer-**breaking** version. your version requirements will be modified to allow this update. spicy. πŸ”₯

  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 info.

- **`-w`, `--workspace`** β€” tries to update only the packages defined in your workspace. other packages only get updated if they don't already exist in the lockfile. this one's lowkey useful for updating `Cargo.lock` after you've changed version numbers in `Cargo.toml`. 🌈

- **`--dry-run`** β€” shows you what *would* be updated, but doesn't actually write the lockfile. window shopping, not shopping. πŸ›οΈ

## πŸ’– Display Options πŸ’–

- **`-v`, `--verbose`** β€” verbose output. and if you say it *twice*, you get "very verbose" output, which includes extra stuff like dependency warnings and build script output. you can also set this with the `term.verbose` config value <https://doc.rust-lang.org/cargo/reference/config.html>.

- **`-q`, `--quiet`** β€” do not print cargo log messages. silence, iconic. 🀫 you can also set this 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:

  - `auto` (**default**): automatically detect if color support is available on the terminal
  - `always`: always display colors
  - `never`: never display colors

  you can also set this 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 `Cargo.toml` in the current directory or any parent directory. it'll find it, don't worry. 🧚

- **`--ignore-rust-version`** β€” ignores 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's for environments where you want deterministic builds β€” like CI pipelines. stable queen behavior. πŸ‘‘

- **`--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 there. with this flag, Cargo will try to proceed without the network if it can. touch grass mode. 🌱

  > beware bestie: this may result in a **different dependency resolution** than online mode. Cargo restricts 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.

  you can also set this 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 combo. ✨

## ⭐ Common Options ⭐

- **`+toolchain`** β€” if Cargo was installed with rustup, and the first argument to `cargo` begins with `+`, it gets interpreted as a rustup toolchain name (like `+stable` or `+nightly`). see the rustup documentation <https://rust-lang.github.io/rustup/overrides.html> for more info on 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 given 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 info.

- **`-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. when in doubt, ask for help. 🫢

- **`-Z`** *flag* β€” unstable (nightly-only) flags to Cargo. run `cargo -Z help` for details. for the risk-takers. πŸ’€

---

# 🌈 ENVIRONMENT 🌈

see the reference <https://doc.rust-lang.org/cargo/reference/environment-variables.html> for details on environment variables that Cargo reads. that's where the tea is. πŸ“

---

# πŸ‘‘ EXIT STATUS πŸ‘‘

- `0`: Cargo succeeded. slay. ✨
- `101`: Cargo failed to complete. 😭

---

# πŸ’œ EXAMPLES πŸ’œ

1. Update all dependencies in the lockfile:
  1. Update only specific dependencies:

3. Set a specific dependency to a specific version:

πŸ”₯ SEE ALSO πŸ”₯

cargo(1), cargo-generate-lockfile(1)


and that's the whole page, bestie πŸ’– this was CARGO-UPDATE(1) from the General Commands Manual β€” go forth and update responsibly, mwah πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from