This is a proof-of-concept Cargo subcommand which is used to vendor all crates.io dependencies into a local directory.
Leveraging file://
URLs, this subcommand will construct a custom registry
index which only contains the necessary packages, cache all necessary crate
files, and then place everything in a structure that Cargo expects.
Currently this can be installed with:
$ git clone https://github.com/alexcrichton/cargo-vendor
$ cd cargo-vendor
$ cargo build --release
Then move the binary target/release/cargo-vendor
into your PATH
or add
target/release
to your PATH
.
First, cd
into a Cargo project's root directory, then run the following
command:
``
$ cargo vendor
Create a
.cargo/config` with this entry to use the vendor cache:
[registry]
index = "file:///home/foo/code/bar/vendor/index"
$ cargo build
Updating registry file:///home/foo/code/bar/vendor/index
Downloading rustc-serialize v0.3.16 (registry file:///home/foo/code/bar/vendor/index)
Compiling rustc-serialize v0.3.16 (registry file:///home/foo/code/bar/vendor/index)
Compiling ...
```
This will populate the vendor
directory (generating an error it if it already
exists) with the index for the "custom registry" as well as a copy of all the
crates needed. The configuration printed can be placed in any .cargo/config
to point your project at that index, and then all future builds will use that
index.
Currently the Cargo.lock
will change depending on whether the index is
crates.io or the local vendor'd copy. This is not always desired and may
require the crates.io Cargo.lock
to be stored next to the vendor'd
Cargo.lock
.
Updating dependencies currently requires going back to the crates.io
Cargo.lock
and then re-vendoring all dependencies.
The vendor directory may not be suitable for checking into a VCS as it contains a git repo itself and also contains tarballs, not checked out contents.