CARGO-FETCH(1)

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

✨ CARGO-FETCH(1) ✨

okay bestie, welcome to the cargo-fetch page from the General Commands Manual β€” it's the one where cargo goes out into the big scary internet and brings back your dependencies like a lil errand runner πŸ›οΈπŸ’–


🌸 NAME 🌸

cargo-fetch β€” grab all the dependencies of a package off the network, no cap πŸ“¦βœ¨


πŸ¦‹ SYNOPSIS πŸ¦‹

cargo fetch [options]

πŸ’… DESCRIPTION πŸ’…

so here's the tea, bestie β˜• β€” if you've got a Cargo.lock file lying around, this command makes sure that every single git dependency and/or registry dependency is downloaded and just sitting there locally, ready for you. and the iconic part? after you run cargo fetch, all your future Cargo commands can run offline β€” unless the lock file changes, obviously πŸ™ˆ

no lock file? no problem, it's giving resourceful πŸ’β€β™€οΈ β€” the command will generate the lock file first and then fetch the deps.

if you don't specify --target, then it fetches all the target dependencies. all of them. every last one. she's thorough 😀

also!! there's a plugin called cargo-prefetch over at https://crates.io/crates/cargo-prefetch that adds a command to download popular crates. super useful if you're planning to use Cargo with no network at all, via 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 may be specified multiple times.

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 get placed in a separate directory. see the build cache docs at https://doc.rust-lang.org/cargo/guide/build-cache.html for the full deets.

πŸ’– 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 πŸ”
  • --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.

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 together. two for one, we love a combo deal πŸ’…

🌈 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 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 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 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 at https://github.com/rust-lang/cargo/issues/10098). yeah. she's exclusive πŸ’…
  • -h, --help β€” prints help information πŸ“–
  • -Z flag β€” unstable (nightly-only) flags to Cargo. run cargo -Z help for details πŸŒ™

🌿 ENVIRONMENT 🌿

see the reference at https://doc.rust-lang.org/cargo/reference/environment-variables.html for the details on which environment variables 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 πŸ₯ΉπŸ’– it came straight out of the General Commands Manual, signed off as CARGO-FETCH(1) at the bottom β€” go forth and fetch, you absolute icon πŸ‘‘βœ¨

πŸ“¦ where this page comes from