cargo publish "crate version is already uploaded" in CI
crates.io already has the version you are publishing, and crate versions can never be overwritten. The release must carry a new version number in Cargo.toml.
What this error means
cargo publish fails with "error: failed to publish to registry at https://crates.io" and a caused-by line "the remote server responded with an error (status 200 OK): crate version X.Y.Z is already uploaded".
error: failed to publish to registry at https://crates.io
Caused by:
the remote server responded with an error (status 200 OK): crate version `1.3.0` is already uploadedCommon causes
The version in Cargo.toml was not bumped
CI published a version that already exists on crates.io. Versions are permanent, so the registry rejects the re-publish.
A duplicated or retried release job
A re-run of a release that already succeeded tries to publish the same version a second time.
How to fix it
Bump the version and publish
- Increment
versionin Cargo.toml. - Commit and tag the new version.
- Run
cargo publishagainst the new version.
# in Cargo.toml: version = "1.3.1"
cargo publishSkip the publish if the version already exists
Guard CI so a re-run does not attempt to republish a version that is already on crates.io.
cargo publish --dry-run && cargo publish || echo "already published"How to prevent it
- Publish only from tagged releases with a fresh version.
- Automate the version bump as part of the release.
- Treat crates.io versions as immutable; never reuse a number.