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://<your-repsy-host>/<repo-name>/"
[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://<your-repsy-host>/<repo-name>/"
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/<your-repsy-host>-*
rm -rf ~/.cargo/registry/cache/<your-repsy-host>-*
Cargo names these folders after the host name of the registry followed by a hash, for example localhost-ee18c9976d7b27b3. <your-repsy-host> is the host name of your Repsy Open Source instance, without the scheme and the port.
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.
A crate with a binary target is installed with cargo install:
cargo install <crate-name> --registry repsy
https://<your-repsy-host> stands for the address of the package protocol port of your Repsy Open Source instance, see Ports and Repository URLs. A deploy token with the Read Only access type is enough to install: see Creating a Deploy Token. The tutorial Publishing and Using Crates with Cargo covers dependencies, cargo install, cargo search and the errors you may meet.