Edit icon Edit This Page

You have registered and created a registry on Repsy. 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://repo.repsy.io/<username>/<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.

You cannot use your repsy password. You should use a Deploy Token or JWT.

To authenticate, run:

cargo login --registry repsy

Cargo asks for the token: paste it and press Enter. Cargo saves it in $HOME/.cargo/credentials.toml. Do not put the token on the command line (cargo login --registry repsy <your-deploy-token>): it still works, but recent Cargo versions warn that it is deprecated, because the token lands in your shell history.

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.

Found a problem with this page?