You have created a registry on your Repsy Open Source instance. You are now ready to publish crates to your registry.
Create a Rust crate
To create a crate, you can use Cargo CLI’s new command:
cargo new hello_repsy
cd hello_repsy
If this command is executed successfully, Cargo will generate a project directory with a Cargo.toml file and source files automatically. This file is required to publish your crates.
Configure your alternate registry
You currently have a basic crate project. The only missing part is the registry configuration and authentication.
Create or update $HOME/.cargo/config.toml in your project as follows:
[registries.repsy]
index = "sparse+https://<your-repsy-host>/<repo-name>/"
[registry]
global-credential-providers = ["cargo:token"]
This configuration defines your Repsy registry for Cargo operations.
Authenticate and publish
In order to successfully publish crates to your cargo registry, you must authenticate.
To authenticate, run:
Cargo sends a single token, not a username and a password. Use a deploy token with the Read/Write access type: the password of a user account does not work as the token.
cargo login --registry repsy <your-deploy-token>
If this command is executed successfully, you will be authenticated and ready to publish your crate. As a final step, please run:
cargo publish --registry repsy
If you have uncommitted changes in your project but want to proceed with the publishing process,
you can use the --allow-dirty flag.
cargo publish --registry repsy --allow-dirty
With this command Cargo will package and publish your crate to your cargo registry.
Congratulations, you have created and published a crate to your registry! You can now install your crate into any project you want and use safely.
https://<your-repsy-host> stands for the address of the package protocol port of your Repsy Open Source instance, for example http://localhost:9090 for a local start, see Ports and Repository URLs. There is no username in the address, and the index address must end with a /.
You can publish a version only once: Repsy refuses a second cargo publish of the same version, whatever the settings of the repository say. Publish a new version instead.
Publishing and Using Crates with Cargo walks through a complete crate, the credentials, what the web UI shows and the errors you may meet.