← 返回命令列表

Linux command

cargo-publish 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Publish to crates.io

cargo publish

Dry run without uploading

cargo publish --dry-run

Publish without verification

cargo publish --no-verify

Allow uncommitted changes

cargo publish --allow-dirty

Publish to alternate registry

cargo publish --registry [my-registry]

Publish specific package

cargo publish -p [crate_name]

说明

cargo publish uploads a package to crates.io or another registry. It creates a `.crate` archive, verifies that the archive builds successfully, and then uploads it to the registry. Authentication is required and is typically set up via `cargo login`. Publishes are permanent and cannot be deleted or overwritten. Once a version is published, that exact version number can never be reused. The `cargo yank` command can mark a version as deprecated to prevent new projects from depending on it, but it remains available for existing users. Before publishing, ensure the version number in Cargo.toml has been incremented according to semver conventions.

参数

--dry-run
Perform checks without uploading
--no-verify
Skip build verification
--allow-dirty
Allow uncommitted VCS changes
--registry _name_
Target registry
--index _url_
Registry index URL
--token _token_
API token
-p, --package _spec_
Package to publish
--target _triple_
Build target for verification
-j, --jobs _n_
Parallel jobs
--features _features_
Enable features for verification
--all-features
Enable all features

FAQ

What is the cargo-publish command used for?

cargo publish uploads a package to crates.io or another registry. It creates a `.crate` archive, verifies that the archive builds successfully, and then uploads it to the registry. Authentication is required and is typically set up via `cargo login`. Publishes are permanent and cannot be deleted or overwritten. Once a version is published, that exact version number can never be reused. The `cargo yank` command can mark a version as deprecated to prevent new projects from depending on it, but it remains available for existing users. Before publishing, ensure the version number in Cargo.toml has been incremented according to semver conventions.

How do I run a basic cargo-publish example?

Run `cargo publish` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --dry-run do in cargo-publish?

Perform checks without uploading