cargo-package --- Assemble the local package into a distributable tarball
cargo package
[options]
This command will create a distributable, compressed .crate
file with the source code of the package in the current directory. The resulting file will be stored in the target/package
directory. This performs the following steps:
dev-dependencies
do not have this restriction..crate
file.Cargo.toml
file is rewritten and normalized.[patch]
, [replace]
, and [workspace]
sections are removed from the manifest.Cargo.lock
is automatically included if the package contains an executable binary or example target. cargo-install(1) will use the packaged lock file if the --locked
flag is used..cargo_vcs_info.json
file is included that contains information about the current VCS checkout hash if available (not included with --allow-dirty
)..crate
file and build it to verify it can build.--no-verify
flag can be used to skip this step.The list of files included can be controlled with the include
and exclude
fields in the manifest.
See the reference for more details about packaging and publishing.
Will generate a .cargo_vcs_info.json
in the following format
{ "git": { "sha1": "aac20b6e7e543e6dd4118b246c77225e3a3a1302" }, "path_in_vcs": "" }
path_in_vcs
will be set to a repo-relative path for packages in subdirectories of the version control repository.
By default, when no package selection options are given, the packages selected depend on the selected manifest file (based on the current working directory if --manifest-path
is not given). If the manifest is the root of a workspace then the workspaces default members are selected, otherwise only the package defined by the manifest will be selected.
The default members of a workspace can be set explicitly with the workspace.default-members
key in the root manifest. If this is not set, a virtual workspace will include all workspace members (equivalent to passing --workspace
), and a non-virtual workspace will include only the root crate itself.
The feature flags allow you to control which features are enabled. When no feature options are given, the default
feature is activated for every selected package.
See the features documentation for more details.
See the reference for details on environment variables that Cargo reads.
0
: Cargo succeeded.101
: Cargo failed to complete.Create a compressed .crate
file of the current package:
cargo package