CARGO-FETCH(1)
π 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
--targettriple β fetch for the given architecture. the default is all architectures. the general format of the triple is<arch><sub>-<vendor>-<sys>-<abi>. runrustc --print target-listfor 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 theterm.verboseconfig 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 theterm.quietconfig value <https://doc.rust-lang.org/cargo/reference/config.html>. the introvert option π€«--colorwhen β 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-pathpath β path to theCargo.tomlfile. by default, Cargo searches for theCargo.tomlfile 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 theCargo.lockfile is up-to-date. if the lock file is missing, or it needs to be updated, Cargo will exit with an error. the--frozenflag 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+stableor+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 π¦--configKEY=VALUE or PATH β overrides a Cargo configuration value. the argument should be in TOML syntax ofKEY=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 π-CPATH β 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 examplecargo -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 π«Ά-Zflag β unstable (nightly-only) flags to Cargo. runcargo -Z helpfor 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 β
0: Cargo succeeded. π slay!!101: Cargo failed to complete. π it's giving tragedy
π EXAMPLES π
- 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
- ubuntu jammy: cargo-1.77 1.77.2+dfsg1ubuntu1~bpo0-0ubuntu0.22.04.1 Β· Apache-2.0 WITH LLVM exception
- ubuntu noble: cargo-1.77 1.77.2+dfsg1ubuntu1-0ubuntu0.24.04.1 Β· MIT OR Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms