cargo
supports alternative registries but does not support authenticated downloads.
cargo-sideload
lets your specify a registry, then reads your Cargo.lock
file to determine
which dependencies use the specified registry. It then downloads the .crate
files for those
dependencies using a user-specified authentication method, and stores them in your local cargo
cache as if they were downloaded directly with cargo
.
The next time you run a cargo
command, it will find the cached .crate
files and use those
instead of attempting to download them.
cargo-sideload
is a workaround until cargo
supports authenticated downloads natively.
cargo install cargo-sideload
~/.cargo/config.toml
.registry = "[registry-name]"
to any dependencies that use the registry.cargo update
to populate your Cargo.lock
file.cargo sideload --registry=[registry-name]
in your crate's root.
CARGO_SIDELOAD_AUTH_HEADER
in your shell or use the --auth-header
flag if your download endpoint requires authentication. Format: [Header-Name]: [Header Value]
.cargo
will use the local copies
rather than attempt to download them.cargo update -p [crate-names]
to update your Cargo.lock
file.cargo sideload --registry=[registry-name]
to download updated dependencies.PRIVATE-TOKEN
header.cargo update
for registry dependencies that are in Cargo.toml
but not Cargo.lock
..crate
files.