Linux command
cargo-vendor 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Vendor dependencies
cargo vendor
Vendor to specific directory
cargo vendor [vendor/]
Vendor and save config
cargo vendor > .cargo/config.toml
Vendor with versioned directories
cargo vendor --versioned-dirs
Vendor specific package
cargo vendor -s [package/Cargo.toml]
说明
cargo vendor downloads and copies all crates.io and git dependencies into a local directory (default: `vendor/`). It outputs the Cargo configuration needed to redirect dependency resolution to the vendored sources. This is primarily used for offline builds, air-gapped environments, and reproducible build systems where network access during compilation is not available or not desired. The vendored sources are read-only; to modify a vendored crate, use the `patch` section in Cargo.toml instead of editing files directly in the vendor directory.
参数
- -s, --sync _path_
- Additional Cargo.toml to sync
- --no-delete
- Don't delete existing vendor directory
- --versioned-dirs
- Use versioned directory names
- --respect-source-config
- Respect source config when vendoring
- --manifest-path _path_
- Path to Cargo.toml
- -v, --verbose
- Verbose output
- -q, --quiet
- Suppress output
FAQ
What is the cargo-vendor command used for?
cargo vendor downloads and copies all crates.io and git dependencies into a local directory (default: `vendor/`). It outputs the Cargo configuration needed to redirect dependency resolution to the vendored sources. This is primarily used for offline builds, air-gapped environments, and reproducible build systems where network access during compilation is not available or not desired. The vendored sources are read-only; to modify a vendored crate, use the `patch` section in Cargo.toml instead of editing files directly in the vendor directory.
How do I run a basic cargo-vendor example?
Run `cargo vendor` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -s, --sync _path_ do in cargo-vendor?
Additional Cargo.toml to sync