cargo package: Usage, Options & Common CI Errors
Assemble and verify a crate tarball without publishing.
cargo package creates the .crate file that cargo publish would upload, then compiles it to verify it builds in isolation. It is the safe dry-run before a release.
What it does
Collects the files cargo would publish into a versioned .crate archive under target/package, then builds that archive to confirm it compiles standalone. --list shows the file set without packaging.
Common usage
cargo package --list # show files that would ship
cargo package # build and verify the .crate
cargo package --no-verify # skip the compile step
cargo package --allow-dirty # ignore uncommitted changesCommon CI error: dirty working directory
cargo package fails with "error: N files in the working directory contain changes that were not yet committed into git" during a release job that generated files. Fix: commit or .gitignore the generated files, or pass --allow-dirty when the changes are intentional and transient.
Options
| Flag | Effect |
|---|---|
| --list | List packaged files, do not build |
| --no-verify | Skip the build verification |
| --allow-dirty | Allow uncommitted changes |