CARGO-FETCH(1)

๐Ÿ“ฆ version 1.88.0, in ubuntu questing

๐Ÿ’– CARGO-FETCH ๐Ÿ’–

okay so bestie, welcome to CARGO-FETCH(1) โ€” yes that's section 1 of the General Commands Manual, we're in the big-girl section now ๐Ÿ’…. This is the page for cargo fetch, and by the end of it you're gonna be fetching deps like it's nothing. no cap. ๐Ÿซถ


โœจ NAME โœจ

cargo-fetch โ€” fetch dependencies of a package from the network ๐ŸŒ๐Ÿ’–


๐ŸŒธ SYNOPSIS ๐ŸŒธ

cargo fetch [options]

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

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. The way that subsequent Cargo commands will be able to run offline after a cargo fetch unless the lock file changes? iconic. โœจ

If the lock file is not available, then this command will generate the lock file before fetching the dependencies. it's giving prepared. ๐Ÿ‘‘

If --target is not specified, then all target dependencies are fetched. all of them. the whole squad. ๐ŸŽ€

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. lowkey a lifesaver for offline vibes ๐ŸŒˆ


๐Ÿ’… 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).

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 documentation (https://doc.rust-lang.org/cargo/reference/build-cache.html) for more details. not me moving your artifacts to a whole new address ๐Ÿ ๐Ÿ’€

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). tell me everything, I wanna know everything ๐Ÿ—ฃ๏ธโœจ
  • -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). shhh ๐Ÿคซ
  • --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. ๐ŸŒˆ periodt
    • 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. it'll go looking for it, don't worry ๐Ÿ•ต๏ธโ€โ™€๏ธ
  • --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 the following 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. deterministic queen behavior fr fr ๐Ÿ‘‘

  • --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. so like, she's working with what she's got ๐Ÿ’€

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. two-for-one deal, we love a combo ๐ŸŽ€
  • --lockfile-path PATH โ€” changes the path of the lockfile from the default (<workspace_root>/Cargo.lock) to PATH. PATH must end with Cargo.lock (e.g. --lockfile-path /tmp/temporary-lockfile/Cargo.lock). Note that providing --lockfile-path will ignore existing lockfile at the default path, and instead will either use the lockfile from PATH, or write a new lockfile into the provided PATH if it doesnโ€™t exist. This flag can be used to run most commands in read-only directories, writing lockfile into the provided PATH. ๐Ÿ—‚๏ธโœจ
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 #14421, https://github.com/rust-lang/cargo/issues/14421). nightly girlies only ๐Ÿ’œ

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 fighter โš”๏ธ
  • --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. 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). โœจ
  • -h, --help โ€” prints help information. when in doubt, ask for help, that's the vibe ๐Ÿ™‹โ€โ™€๏ธ
  • -Z flag โ€” unstable (nightly-only) flags to Cargo. Run cargo -Z help for details. the secret menu ๐Ÿ”ฎ

๐ŸŒˆ ENVIRONMENT ๐ŸŒˆ

See the reference (https://doc.rust-lang.org/cargo/reference/environment-variables.html) for details on environment variables that Cargo reads. Cargo's out here reading env vars like they're the group chat ๐Ÿ“ฑ๐Ÿ‘€


โญ EXIT STATUS โญ

  • 0: Cargo succeeded. ๐ŸŽ‰ slay
  • 101: Cargo failed to complete. ๐Ÿ˜ญ rip

๐Ÿงš EXAMPLES ๐Ÿงš

  1. Fetch all dependencies:
cargo fetch

that's it. that's the whole thing. go get your deps bestie ๐Ÿ’–


๐Ÿ”ฅ SEE ALSO ๐Ÿ”ฅ

cargo(1), cargo-update(1), cargo-generate-lockfile(1) โ€” the rest of the girlies, go say hi ๐Ÿ‘‘


and that's the whole page!! this footer's just CARGO-FETCH(1) again โ€” same name, General Commands Manual, section 1 โ€” no version stamp or date on it, she's simply timeless like that ๐Ÿ’…โœจ mwah, go fetch something ๐Ÿซถ

๐Ÿ“ฆ where this page comes from