CARGO-FETCH(1)

πŸ“¦ version 1.93.1, in ubuntu resolute

πŸ’– cargo-fetch(1) πŸ’–

hey bestie!! welcome to the manual page for cargo-fetch, straight outta the General Commands Manual, section 1 πŸŽ€ this is the lil command that goes and grabs all ur deps off the internet so u can vibe offline later. no cap. let's get into it ✨


🌸 NAME 🌸

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


πŸ¦‹ SYNOPSIS πŸ¦‹

cargo fetch [options]

✨ DESCRIPTION ✨

okay so here's the tea β˜• 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 the best part?? subsequent Cargo commands will be able to run offline after a cargo fetch β€” unless the lock file changes, in which case rip, gotta redo it 😭

if the lock file is not available, then this command will generate the lock file before fetching the dependencies. so it's out here doing double duty, iconic behavior fr fr πŸ‘‘

if --target is not specified, then all target dependencies are fetched. all of them. every single one. we're not leaving anyone out πŸ’–

also!! see also the cargo-prefetch plugin at 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 life saver iykyk


πŸ‘‘ OPTIONS πŸ‘‘

🌈 Fetch options

  • --target triple β€” fetch for the specified target architecture. the flag may be specified multiple times, so go off bestie 🫢 the default is all architectures. the general format of the triple is <arch><sub>-<vendor>-<sys>-<abi>.

Possible values:

  • any supported target in rustc --print target-list πŸ’«
  • "host-tuple", which will internally be substituted by the host's target. this can be particularly useful if you're cross-compiling some crates, and don't want to specify your host's machine as a target (for instance, an xtask in a shared project that may be worked on by many hosts). very main character energy of it tbh
  • a path to a custom target specification. see Custom Target Lookup Path at 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 at 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 docs at https://doc.rust-lang.org/cargo/reference/build-cache.html for more details. not me warning u twice, it's important πŸ’€

πŸŽ€ 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 at 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 at https://doc.rust-lang.org/cargo/reference/config.html.
  • --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 at 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 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. periodt πŸ’―

  • --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, no FOMO but also maybe FOMO.

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

  • --frozen β€” equivalent to specifying both --locked and --offline. two for one deal, we love a bundle 🧚
  • --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 (see https://doc.rust-lang.org/book/appendix-07-nightly-rust.html) and requires the -Z unstable-options flag to enable (see #14421 at https://github.com/rust-lang/cargo/issues/14421).

⭐ 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 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 at 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 (see 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).
  • -h, --help β€” prints help information. the classic 🫢
  • -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 details on environment variables that Cargo reads πŸ“–


🚦 EXIT STATUS 🚦

  • 0: Cargo succeeded. slay πŸŽ‰
  • 101: Cargo failed to complete. it's giving tragic 😭

πŸ’« 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!! πŸ’– this was cargo-fetch(1) from the General Commands Manual (section 1) β€” go forth and fetch ur deps, u got this πŸŒˆβœ¨πŸŽ€

πŸ“¦ where this page comes from