Documentation Index
Fetch the complete documentation index at: https://mintlify.com/harness/harness-cli/llms.txt
Use this file to discover all available pages before exploring further.
Harness Artifact Registry provides support for Rust Cargo crates, allowing you to host private Rust libraries.
Overview
Cargo registry features:
- Standard Cargo registry protocol
- Automatic metadata extraction from
Cargo.toml
.crate file format support
- Version management following SemVer
- Integration with cargo CLI
Pushing Cargo crates
Use the hc artifact push cargo command:
hc artifact push cargo <registry-name> <crate-file-path> \
--pkg-url <pkg-url>
How it works
The CLI automatically:
- Validates the
.crate file format
- Extracts metadata from the crate’s
Cargo.toml
- Reads the crate name and version
- Uploads the crate to the registry
Building Cargo crates
Prepare your crate
Ensure your Cargo.toml has proper metadata:[package]
name = "my-crate"
version = "0.1.0"
edition = "2021"
authors = ["Your Name <you@example.com>"]
description = "A useful crate"
license = "MIT"
Package the crate
Create the .crate file:This creates target/package/my-crate-0.1.0.crate Upload to registry
Push the crate:hc artifact push cargo my-registry ./target/package/my-crate-0.1.0.crate \
--pkg-url https://app.harness.io/registry/pkg
Using Cargo crates
Configure Cargo to use your Harness registry:
In .cargo/config.toml
Create or edit .cargo/config.toml:
[registries.harness]
index = "https://<registry-url>/index"
[registry]
default = "harness"
Authentication
Configure credentials:
# Using cargo credentials
cargo login --registry harness <your-harness-token>
Or manually in ~/.cargo/credentials.toml:
[registries.harness]
token = "<your-harness-token>"
Installing crates
# Add dependency to Cargo.toml
[dependencies]
my-crate = { version = "0.1.0", registry = "harness" }
# Build your project
cargo build
Examples
# Package and push
cargo package
hc artifact push cargo my-registry ./target/package/my-crate-0.1.0.crate \
--pkg-url https://app.harness.io/registry/pkg
Cargo.toml requirements
The Cargo.toml must contain name and version in the [package] section
Minimal configuration:
[package]
name = "my-crate"
version = "0.1.0"
edition = "2021"
Recommended fields:
[package]
name = "my-crate"
version = "0.1.0"
edition = "2021"
authors = ["Your Name <you@example.com>"]
description = "A useful Rust library"
license = "MIT OR Apache-2.0"
repository = "https://github.com/yourusername/my-crate"
keywords = ["rust", "library"]
categories = ["development-tools"]
CI/CD integration
- name: Build and publish
run: |
cargo package
hc artifact push cargo my-registry ./target/package/*.crate \
--pkg-url https://app.harness.io/registry/pkg
env:
HARNESS_API_KEY: ${{ secrets.HARNESS_API_KEY }}
publish:
script:
- cargo package
- hc artifact push cargo my-registry ./target/package/*.crate --pkg-url $PKG_URL
variables:
HARNESS_API_KEY: $HARNESS_TOKEN
Version requirements
Cargo uses Semantic Versioning (SemVer):
- Major.Minor.Patch:
1.0.0
- Pre-release:
1.0.0-alpha, 1.0.0-beta.1
- Build metadata:
1.0.0+build.123
Troubleshooting
Failed to extract metadata
Crate name/version mismatch
The .crate filename must match the name and version in Cargo.toml:# ✅ Correct
my-crate-0.1.0.crate # matches Cargo.toml name="my-crate" version="0.1.0"
Check your Cargo credentials:# Re-login
cargo login --registry harness <your-token>
# Or check ~/.cargo/credentials.toml
cat ~/.cargo/credentials.toml
See also