Cargo Registry

Cloudsmith provides public & private registries for Cargo (Rust)


For more information on Rust, please see:

  • Rust: The official website for Rust language
  • Cargo: The official documentation for Cargo - the Rust package manager
  • Crates Public Registry: The official Rust community’s crate registry
Contextual Documentation

The examples in this document are generic. Cloudsmith provides contextual setup instructions within each repository, complete with copy n' paste snippets (with your namespace/repo pre-configured).

In the following examples:

OWNERYour Cloudsmith account name or organisation name (namespace)
REPOSITORYYour Cloudsmith Repository name (also called "slug")
VERSIONAlpine distribution version, i.e v3.8
TOKENYour Cloudsmith Entitlement Token (see Entitlements for more details)
USERNAMEYour Cloudsmith username
PASSWORDYour Cloudsmith password
API-KEYYour Cloudsmith API Key
REGISTRY_NAMEA name for the Cargo registry
PACKAGE_NAMEThe name of your package
PACKAGE_VERSIONThe version number of your package
PROJECT_NAMEThe name of your Rust project

Upload a Package

Upload via Cargo Publish


A name and URL for the registry must be added to your .cargo/config file as follows:

Public Repositories

REGISTRY_NAME = { index = "" }

Private Repositories


Private Cloudsmith repositories require authentication. You can choose between two types of authentication, Entitlement Token Authentication or HTTP Basic Authentication.

The setup method will differ depending on what authentication type you choose to use.


Entitlement Tokens, User Credentials and API-Keys should be treated as secrets and you should ensure that you do not commit them in configurations files along with source code, or expose them in any logs

REGISTRY_NAME = { index = "" }
REGISTRY_NAME = { index = "" }

If using HTTP basic authentication, you'll need to configure Git with credentials. Git's standard authentication mechanisms are used by Cargo and can be configured in the normal way. For example, you could use git's per-user credential store as follows:

git config --global credential.helper store
echo "https://USERNAME:[email protected]" > ~/.git-credentials
git config --global credential.helper store
echo "https://USERNAME:[email protected]" > ~/.git-credentials
git config --global credential.helper store
echo "https://token:[email protected]" > ~/.git-credentials

For further details or other configuration options, see the Official Git Documentation.

In order to authenticate for publishing via cargo, you can either enter your credentials using the command:

cargo login --registry REGISTRY_NAME

Or, add your credentials to your .cargo/credentials file:

token = API-KEY


To publish a crate, you can do so from your project directory using cargo publish as follows:

cargo publish --registry REGISTRY_NAME

If you haven't specified credentials using one of the methods above, you'll be asked to provide them using cargo login.

You can also set the following environment variables:
CARGO_REGISTRIES_<REGISTRY_NAME>_INDEX - instead of setting the registry URL in ~/.cargo/config
CARGO_REGISTRIES_<REGISTRY_NAME>_TOKEN - instead of providing credentials via cargo login or writing them to ~/.cargo/credentials:

Upload via the Cloudsmith CLI

For full details of how to install and setup the Cloudsmith CLI, see Command Line Interface.

The command to upload a cargo crate via the Cloudsmith CLI is:

cloudsmith push cargo OWNER/REPOSITORY PACKAGE_NAME.crate


cloudsmith push cargo org/repo your-package.crate

Upload via Cloudsmith Website

Please see Upload a Package for details of how to upload via the Website UI.

Download a Package

Registry Setup

It is easy to add a Cloudsmith-based Cargo registry.


Cargo Sparse Registry

Cargo Sparse Registries are a new addition to Cargo as of v1.68.0, and are the recommended way to interact with your Cloudsmith Repositories - they offer significant performance advantages over the old Git-based registries, such as reducing the bandwidth used and improving dependency resolution times.

First, the name and config for the registry must be added to your .cargo/config.toml or .cargo/config file as follows:

Cargo >= v1.74 (HTTP Sparse Registry)

index = "sparse+"
token = "Token API-KEY"
credential-provider = "cargo:token"
index = "sparse+"
token = "Token TOKEN"
credential-provider = "cargo:token"

Cargo < v1.74 (HTTP Sparse Registry)
If you are using Cargo version < 1.74, the only way to authenticate with a private sparse registry is using Cloudsmith's URL-based authentication.

index = "sparse+"

Cargo < v1.68 (Legacy Git Registry)

OWNER-REPOSITORY = { index = "" }
OWNER-REPOSITORY = { index = "" }

Registry Authentication

You must configure Git with the proper credentials to clone the registry when using HTTP basic authentication. Git's standard authentication mechanisms are used by Cargo and can be configured normally. For example, you could use git's per-user credential store like so:

git config --global credential.helper store
echo "https://USERNAME:[email protected]" > ~/.git-credentials

When using URL-based authentication, no further configuration is required, you're all set up and ready to go.

Install a Package

Once you have configured a registry using one of the methods described above, a crate can then depend on a crate from your registry by specifying the registry key and a value of the registry's name in that dependency's entry in Cargo.toml:

version = "0.1.0"
PACKAGE_NAME = { version = "PACKAGE_VERSION", registry = "REGISTRY_NAME" }

You can also install a crate directly by specifying the registry on the command line:

cargo install PACKAGE_NAME --registry REGISTRY_NAME`

Security Scanning

Please see our Security Scanning documentation for further information.

Upstream Proxying / Caching

Not Supported


When you install a Cargo package, cargo will assume that all dependencies are available in your Cloudsmith repository. You can configure your Cloudsmith repository to fetch any dependencies from that are not already present. See the repository Main Settings for further information.

Key Signing Support

Not Supported by Format


Please see the Troubleshooting page for further help and information.

Cloudsmith is the new standard in Package / Artifact Management and Software Distribution

With support for all major package formats, you can trust us to manage your software supply chain.

Start My Free Trial Now
Cookie Declaration (Manage Cookies)