CARGO-FETCH(1)

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

πŸ’– cargo-fetch β€” the manual page, but make it cute ✨

okay bestie, welcome to cargo-fetch, section 1 of the General Commands Manual. it's a Cargo command. it's gonna go get your dependencies. that's the whole vibe. let's get into it πŸŽ€


🌸 NAME 🌸

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


πŸ¦‹ SYNOPSIS πŸ¦‹

cargo fetch [options]

that's it. that's the whole thing. she's simple. she's iconic. πŸ‘‘


✨ DESCRIPTION ✨

okay so here's the tea, bestie 🍡:

if a Cargo.lock file is available, this command will make sure that all of the git dependencies and/or registry dependencies are downloaded and locally available. and then β€” the slay part β€” subsequent Cargo commands will be able to run offline after a cargo fetch, unless the lock file changes. yes, that's the deal. lock file changes, you're back online, sorry bestie 😭

if the lock file is not available, then this command will generate the lock file before fetching the dependencies. she'll make it herself. self-sufficient queen. πŸ’…

if --target is not specified, then all target dependencies are fetched. all of them. every single one. no crumbs left. πŸ“

alsoooo, see also the cargo-prefetch plugin <https://crates.io/crates/cargo-prefetch> which adds a command to download popular crates. this may be useful if you plan to use Cargo without a network with 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. no cap. ✨

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

⚠️ note that 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. don't say i didn't warn you 🫢

🌈 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>. she's chatty, love that for her πŸ’¬
  • -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>. the introvert option 🀫
  • --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 <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'll go looking for it, she's thorough πŸ”
  • --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. very "i said what i said" energy, and honestly? respect. πŸ’…

  • --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. plan ahead bestie, fr fr.

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. pick your girl, choose your era πŸ¦‹
  • --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. stack those flags, why not πŸ’–
  • -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. order matters bestie, don't fight it ⭐
πŸŒ™ 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>). nightlies only, no cap.
  • -h, --help β€” prints help information. when you're lost, she's there 🫢
  • -Z flag β€” unstable (nightly-only) flags to Cargo. run cargo -Z help for details. ✨ the forbidden zone. only for the brave.

🌈 ENVIRONMENT 🌈

see the reference <https://doc.rust-lang.org/cargo/reference/environment-variables.html> for details on environment variables that Cargo reads. yes she's reading your env vars. she's nosy like that. we love a curious queen πŸ‘‘


⭐ EXIT STATUS ⭐

  1. 0: Cargo succeeded. πŸŽ‰ slay!!
  2. 101: Cargo failed to complete. πŸ’€ it's giving tragedy

πŸŽ€ EXAMPLES πŸŽ€

  1. Fetch all dependencies:
cargo fetch

literally one line and you're done. main character energy fr fr ✨


πŸ’œ SEE ALSO πŸ’œ

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

go read those too, bestie, they're all connected 🧚


and that's the whole page!! πŸ’– this was cargo-fetch(1) from the General Commands Manual β€” section 1, your girl, your dependency fetcher. mwah, ily, go run cargo fetch and stay hydrated πŸ“πŸ¦‹βœ¨

πŸ“¦ where this page comes from