CARGO-FETCH(1)

๐Ÿ’– CARGO-FETCH(1) ๐Ÿ’–

okay so bestie, you've stumbled into the General Commands Manual entry for cargo-fetch, and honestly? it's giving errand runner for your crate dependencies. let's get into it ๐ŸŽ€


โœจ NAME โœจ

cargo-fetch โ€” fetch dependencies of a package from the network ๐Ÿฆ‹


๐ŸŒธ SYNOPSIS ๐ŸŒธ

cargo fetch [options]

๐Ÿ’… DESCRIPTION ๐Ÿ’…

so here's the tea: if you've got a Cargo.lock file hanging around, this command makes sure that every single one of your git dependencies and/or registry dependencies is downloaded and locally available. and the payoff? after a cargo fetch, all your subsequent Cargo commands can just run offline โ€” no cap โ€” unless the lock file changes. then it's back to the internet, sorry babe ๐Ÿ˜ญ

if there's no lock file available? no problem. this command will generate the lock file first, and then go fetch the dependencies. main character behavior tbh ๐Ÿ‘‘

and one more thing: if --target isn't specified, then all target dependencies get fetched. all of them. periodt.


๐ŸŽ€ OPTIONS ๐ŸŽ€

๐Ÿ›๏ธ Fetch options

  • --target triple โ€” fetch for the target architecture you name. this flag can be specified multiple times (yes, really). the default is all architectures. the general format of the triple is <arch><sub>-<vendor>-<sys>-<abi>.

Possible values, bestie:

  • Any supported target in rustc --print target-list.
  • "host-tuple", which will internally be substituted by the host's target. this one is particularly useful if you're cross-compiling some crates and you don't wanna specify your host's machine as a target โ€” for instance, an xtask in a shared project that may be worked on by many hosts. shared-project girlies, this one's for you ๐Ÿซถ
  • A path to a custom target specification. see Custom Target Lookup Path <https://doc.rust-lang.org/rustc/targets/custom.html#custom-target-lookup-path> for more information.

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

heads up ๐Ÿ’€ 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/reference/build-cache.html> documentation for more details.

๐ŸŒˆ Display Options

  • -v, --verbose โ€” use verbose output. you can specify it 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>. 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.
    • 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 will find it, bestie, it always does ๐Ÿ”
  • --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. CI girlies rise up โœจ

  • --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 ๐Ÿ˜ญ 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. two-for-one, iconic ๐Ÿ’…

๐Ÿ‘‘ 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>). nightlies only, bestie, sorry ๐Ÿซ 
  • -h, --help โ€” prints help information. classic.
  • -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. env vars stay winning ๐Ÿ’œ


โญ EXIT STATUS โญ

  • 0: Cargo succeeded. slay ๐ŸŽ‰
  • 101: Cargo failed to complete. it's giving tragedy ๐Ÿ’€

๐ŸŒˆ 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) from the General Commands Manual, brought to you by the Cargo crew (no version or date on this one, it's mysterious like that ๐Ÿ’…). go fetch your deps and hydrate. you got this ๐Ÿซถโœจ

๐Ÿ“ฆ where this page comes from