cargo vendor: Usage, Options & Common CI Errors
Vendor all dependencies into the repo for offline builds.
cargo vendor downloads every dependency source into a local folder (default vendor/) and prints the .cargo/config.toml snippet that redirects cargo to use it. Builds then need no registry access.
What it does
Copies the source of all locked dependencies into a directory and emits a [source] replacement config. Commit the directory (or restore it in CI) to build fully offline and reproducibly.
Common usage
cargo vendor # writes ./vendor and prints config
cargo vendor third-party # custom directory
cargo vendor > .cargo/config.toml # capture the source replacementCommon CI error: vendor not configured
A vendored build still hits the network and fails because the printed [source.crates-io] replace-with config was never added to .cargo/config.toml. Fix: paste the snippet cargo vendor prints into .cargo/config.toml, then build with --offline. If the vendor dir drifts from Cargo.lock, re-run cargo vendor.
Options
| Flag | Effect |
|---|---|
| <path> | Output directory (default vendor) |
| --versioned-dirs | Include version in dir names |
| --no-delete | Keep extra files in the dir |