CARGO-FETCH(1)

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

CARGO-FETCH πŸ’– (1)

okay bestie, welcome to the General Commands Manual corner of the cargo universe β€” this is the cargo-fetch page and it's about to be your new fave for hoarding dependencies like they're limited-edition Squishmallows 🧸✨


✨ NAME ✨

cargo-fetch β€” Fetch dependencies of a package from the network πŸŒπŸ’«


🌸 SYNOPSIS 🌸

cargo fetch [options]

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the vibe: if you've got a Cargo.lock file sitting there, this command makes sure every single git dependency and/or registry dependency is downloaded and chillin' locally on your machine. and the slay part? after a cargo fetch, all your future Cargo commands can run offline β€” unless the lock file changes, in which case, yeah, we're back online babes 😭

and if the lock file isn't there yet? no stress. this command generates the lock file first, then goes and fetches everything. main character energy fr fr πŸ‘‘

if you don't specify --target, then all target dependencies get fetched. all of them. every last one. we're thorough like that πŸ’…

also!! there's a plugin called cargo-prefetch <https://crates.io/crates/cargo-prefetch> that adds a command to download popular crates. lowkey useful if you're planning to use Cargo without a network using the --offline flag. iykyk 🌈


πŸŽ€ OPTIONS πŸŽ€

πŸ’œ Fetch options

  • --target triple β€” Fetch for the given architecture. the default is all architectures. the general format of the triple is <arch><sub>-<vendor>-<sys>-<abi>. run rustc --print target-list for a list of supported targets. this flag can be specified multiple times (yes queen, stack 'em) ✨

This may also be specified with the build.target config value <https://doc.rust-lang.org/cargo/reference/config.html>.

heads up bestie ⚠️ specifying this flag makes Cargo run in a different mode where the target artifacts are placed in a separate directory. see the build cache <https://doc.rust-lang.org/cargo/guide/build-cache.html> documentation for more details.

🌈 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 <https://doc.rust-lang.org/cargo/reference/config.html>. πŸ—£οΈ
  • -q, --quiet β€” Do not print cargo log messages. may also be specified with the term.quiet config value <https://doc.rust-lang.org/cargo/reference/config.html>. 🀫
  • --color when β€” Control 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. πŸ”
  • --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.

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

May also be specified with the net.offline config value <https://doc.rust-lang.org/cargo/reference/config.html>.

πŸ‘‘ 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. πŸ†˜
  • -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. 🌱


πŸ’… EXIT STATUS πŸ’…

  • 0: Cargo succeeded. πŸŽ‰
  • 101: Cargo failed to complete. 😭

⭐ EXAMPLES ⭐

  1. Fetch all dependencies:
cargo fetch

🫢 SEE ALSO 🫢

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


and that's the whole page, bestie!! cargo-fetch(1) β€” this page came straight out of the General Commands Manual (that's the source, mwah πŸ’‹), so go forth, fetch those deps, and stay offline-ready. periodt. πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from