Skip to content

Cargo sparse registries, publishing, and yanking ​

Cargo reads crate versions and checksums from a sparse index and publishes to Hosted through the publish API. The example upstream serves both a sparse index and crate downloads.

Create repositories ​

Run these Bash commands with an authenticated administrator arkactl profile and jq. Replace the example address with your HTTPS endpoint. Publish to Hosted. Group looks in Hosted first, then in Proxy. Grant the publishing account write access to Hosted and the consuming account read access to Group and the relevant members.

For each consuming or publishing identity, sign in with its profile and run arkactl --json tokens create --name cargo-ci --expires-in-days 30 | jq -er .plaintext. Send the output directly to the CI secret store. Use a separate read and write token for the examples below.

bash
export ARKA_URL=https://packages.example.org
hosted=$(arkactl --json repo create --name cargo-hosted --type hosted --format cargo | jq -er .id)
proxy=$(arkactl --json repo create --name cargo-proxy --type proxy --format cargo \
  --upstream-url https://upstream.example.org/repository/cargo/ | jq -er .id)
arkactl repo create --name cargo-group --type group --format cargo --member "$hosted,$proxy"
WRITE="$ARKA_URL/repository/cargo-hosted"
READ="$ARKA_URL/repository/cargo-group"

Configure registries and credentials ​

Use separate publishing and reading entries in the project’s .cargo/config.toml. Add a trailing slash to both index URLs. Inject CARGO_REGISTRIES_ARKA_WRITE_TOKEN with the publisher’s raw arkat_… token. Set CARGO_REGISTRIES_ARKA_READ_TOKEN if the read registry requires authentication.

toml
[registries.arka-write]
index = "sparse+https://packages.example.org/repository/cargo-hosted/"
credential-provider = "cargo:token"

[registries.arka-read]
index = "sparse+https://packages.example.org/repository/cargo-group/"
credential-provider = "cargo:token"
bash
cargo publish --registry arka-write
# Run in a consuming project after declaring the dependency.
cargo fetch
cargo build --offline --locked

For example, add widget = { version = "=1.2.3", registry = "arka-read" } to the consuming project’s Cargo.toml. Arka serves the api and dl endpoints in config.json. The current response omits auth-required. Isolated verification covers anonymous reads, token publishing, and yanking. Verify private indexes and downloads with your Cargo version and account.

Yank a version ​

bash
cargo yank --registry arka-write --version 1.2.3 widget
curl -fsS -H "Authorization: Bearer $ARKA_WRITE_TOKEN" "$WRITE/wi/dg/widget"

Check that the index record for the version has yanked: true. Existing lockfiles can still reference it. Restore it with cargo yank --undo --registry arka-write --version 1.2.3 widget.

SymptomWhat to check
Credential provider missingCheck that the configuration and environment variable use the same registry. Convert hyphens to underscores in variable names.
Index loads but crate download returns 404Check dl in config.json and the public base URL. Proxy tries api/v1/crates/<name>/<version>/download first, then the repository storage path. The public crates.io index and crate files are on different domains, so setting the upstream to the index domain alone may omit archives.
Local build works but CI cannot find the versionRetry with an empty CARGO_HOME. Check read access to Group members and the version and yanked flag in the sparse index.

Cargo registry authentication

Released under the Apache 2.0 License.