Troubleshooting: 'I Can Publish, But Not Download'
One situation you can find yourself in is that you can publish crates, but not depend on them.
Publishing goes great, the .crate
file gets uploaded to the server, and everything seems like
it's finally in place.
But then you add the crate you published as a dependency in a second crate:
# Cargo.toml
[dependencies]
my-first-publish = { version = "*", registry = "shipyard-rs" }
...and it all falls apart:
$ cargo check
Updating `shipyard-rs` index
error: failed to download from `https://crates.shipyard.rs/api/v1/crates/my-first-publish/0.1.0/download`
Caused by:
failed to get 200 response from `https://crates.shipyard.rs/api/v1/crates/my-first-publish/0.1.0/download`, got 403
The problem is likely created by not configuring cargo
to send an auth token (see Credential Process).
Example configuration:
# ~/.cargo/config.toml
#
# or
#
# ~/path/to/crate/.cargo/config.toml
[registry]
global-credential-providers = ["cargo:token"]
[registries.my-crate-registry]
index = "https://git.shipyard.rs/my-org/crate-index.git"
After authenticating via cargo login
to provide a token, you should be able to download crates successfully:
$ cargo check
Downloaded my-first-publish v0.1.0 (registry `shipyard-rs`)
Downloaded 1 crate (811 B) in 0.53s
Checking my-first-publish v0.1.0 (registry `shipyard-rs`)
Checking dep-test v0.1.0 (/home/jstrong/src/dep-test)
Finished dev [unoptimized + debuginfo] target(s) in 0.65s