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_HEADERS
in your shell or use the --headers
argument
if your download endpoint requires authentication or other headers.
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.--force
will force cargo sideload
to download a new copy of the specified .crate
files.
Previous copies of the .crate
file for that crate will be deleted.cargo update
for registry dependencies that are in Cargo.toml
but not Cargo.lock
..crate
files.