LinuxCommandLibrary

cargo-fetch

Download dependencies for offline builds

TLDR

Fetch all dependencies

$ cargo fetch
copy
Fetch for specific target
$ cargo fetch --target [x86_64-unknown-linux-gnu]
copy
Fetch with locked versions
$ cargo fetch --locked
copy
Fetch offline (from cache)
$ cargo fetch --offline
copy

SYNOPSIS

cargo fetch [options]

DESCRIPTION

cargo fetch downloads all dependencies from the network and stores them locally. If Cargo.lock exists, fetches exact versions specified. Otherwise, generates the lock file first.
Useful for preparing to work offline with the --offline flag.

PARAMETERS

--target triple

Fetch for specified target architecture (can be repeated)
--locked
Assert same dependencies as original Cargo.lock
--offline
Use only locally cached crates
--frozen
Equivalent to --locked and --offline
--manifest-path path
Path to Cargo.toml
-v, --verbose
Verbose output
-q, --quiet
Suppress log messages

BEHAVIOR

Without --target, fetches all target dependencies. Git dependencies are cloned with submodules. Registry crates are downloaded to cargo cache.

CAVEATS

Subsequent cargo commands can run offline after fetch unless lock file changes. Network access required unless using --offline with cached dependencies.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community