Skip to content
Latchkey

cargo publish: Usage, Options & Common CI Errors

Package and upload your crate to a registry.

cargo publish builds a .crate package, verifies it compiles, and uploads it to crates.io (or another registry). Publishing is permanent - a version cannot be overwritten.

What it does

Runs the equivalent of cargo package, compiles the packaged crate to verify it, then uploads it to the registry using your auth token. Required metadata (license, description) must be present.

Common usage

Terminal
cargo publish --dry-run           # validate without uploading
cargo publish                     # publish to crates.io
cargo publish --token "${CARGO_REGISTRY_TOKEN}"
cargo publish --no-verify         # skip the compile check

Common CI error: version already exists

A release re-run fails with "error: crate version 1.2.3 is already uploaded." crates.io is immutable, so you cannot republish a version. Fix: bump the version in Cargo.toml. For missing metadata, "error: missing field license" means you must set license or license-file in [package].

Options

FlagEffect
--dry-runValidate, do not upload
--token <t>Registry auth token
--no-verifySkip the build verification
--allow-dirtyPublish with uncommitted changes

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →