Edit icon Edit This Page

When you create a registry, it will be private by default. Before you install a crate from a private registry, you first need to authenticate as seen in the previous page. If your registry is public, you can skip the authentication part, but you must still indicate the registry that you want to use.

Therefore, you need to set Cargo configuration as follows:

Create or edit $HOME/.cargo/config.toml file

[registries.repsy]
index = "sparse+https://repo.repsy.io/<username>/<registryName>/"

[registry]
global-credential-providers = ["cargo:token"]

Note: If your repository is public, and you are only downloading packages, do not add global-credential-providers to your config. Your $HOME/.cargo/config.toml should look like this:

[registries.repsy]
index = "sparse+https://repo.repsy.io/<username>/<registryName>/"

Tip: Cargo caches registry index and crate data locally. If you encounter stale index data or unexpected resolution errors after publishing a new version to Repsy, you may need to clear the cache manually.

Clear the Repsy registry cache only:

rm -rf ~/.cargo/registry/index/*repsy*
rm -rf ~/.cargo/registry/cache/*repsy*

Or clear the entire Cargo registry cache:

rm -rf ~/.cargo/registry/

After clearing, the next cargo install or cargo build will re-fetch the index from Repsy automatically.

If you do authenticate, you do not have to repeat token setup on every command, but $HOME/.cargo/config.toml is still required for registry resolution.

You can now install any crate from the registry. Please run:

cargo add <crate_name> --registry repsy

Or define the dependency directly in Cargo.toml:

[dependencies]
<crate_name> = { version = "<version>", registry = "repsy" }

That is all! If you have completed all required steps as described, Cargo will install your crate from your registry successfully.

Was this page helpful?