Skip to main content

cargo-quickstart

Last updated on

Prerequisites

  • Ensure you have the Cargo CLI (cargo) installed on your local machine.
  • Access to a Harness account with appropriate permissions to create registries and connectors.

Create a Cargo artifact registry

private registry

This registry will serve as your private Cargo registry within Harness.


Configure an Upstream Proxy (Optional)

An upstream proxy allows your registry to fetch Cargo packages from external sources if they are not available locally.

Create an upstream proxy

Configure the upstream proxy in your registry

upstream proxy caching

If a Cargo package isn’t found in your Harness registry, the upstream proxy can fetch it from an external source like Cargo.io, helping to reduce duplication and ensure reliable access to public packages.


Publish & Install Cargo Packages

Configure authentication

  • In your Harness Cargo Artifact Registry, click Setup Client.
  1. Create or update your ~/.cargo/config.toml file and add the following configuration:
[registry]
global-credential-providers = ["cargo:token", "cargo:libsecret", "cargo:macos-keychain", "cargo:wincred"]

[registries.harness-cargo-registry]
index = "sparse+https://pkg.app.harness.io/pkg/<harness-account-id>/<cargo-registry-name>/cargo/index/"

After creating your new Cargo registry, you will need to set up a client to authenticate with the registry.

  1. Click Generate token to generate a new identity token for CLI access.
  2. Create or update your ~/.cargo/credentials file and add the following configuration:
[registries.harness-cargo-registry]
token = "Bearer <token from step 2>"

Publish a package

Publish your package with the following command:

cargo publish --registry harness-cargo-registry

Install a package

Install your package with the following command:

cargo add <ARTIFACT_NAME>@<VERSION> --registry harness-cargo-registry