LinuxCommandLibrary

cargo-package

TLDR

Create package archive

$ cargo package
copy
Package without verification
$ cargo package --no-verify
copy
List files in package
$ cargo package --list
copy
Allow uncommitted changes
$ cargo package --allow-dirty
copy
Package specific workspace member
$ cargo package -p [crate_name]
copy

SYNOPSIS

cargo package [options]

DESCRIPTION

cargo package creates a distributable .crate archive from the source code. Output is placed in target/package/. The archive is verified by extracting and building unless --no-verify is used.

PARAMETERS

-l, --list

List files that would be included
--no-verify
Skip extraction and build verification
--allow-dirty
Allow uncommitted VCS changes
--no-metadata
Ignore warnings about missing metadata
--exclude-lockfile
Don't include Cargo.lock
--target triple
Build for target platform (verification)
-p, --package spec
Package specific workspace member
--workspace
Package all workspace members
-v, --verbose
Verbose output

MANIFEST PROCESSING

The Cargo.toml is normalized:
- [patch], [replace], [workspace] sections removed
- Path dependencies require version key
- Cargo.lock included by default

FILE CONTROL

Use include/exclude fields in Cargo.toml to control packaged files.

CAVEATS

crates.io has 10MB size limit. Path dependencies without version keys are not allowed. Equivalent to cargo publish --dry-run.

SEE ALSO

Copied to clipboard