1CARGO-PACKAGE(1)            General Commands Manual           CARGO-PACKAGE(1)
2
3
4

NAME

6       cargo-package - Assemble the local package into a distributable tarball
7

SYNOPSIS

9       cargo package [options]
10

DESCRIPTION

12       This command will create a distributable, compressed .crate file with
13       the source code of the package in the current directory. The resulting
14       file will be stored in the target/package directory. This performs the
15       following steps:
16
17        1. Load and check the current workspace, performing some basic checks.
18
19           •  Path dependencies are not allowed unless they have a version
20               key. Cargo will ignore the path key for dependencies in
21               published packages. dev-dependencies do not have this
22               restriction.
23
24        2. Create the compressed .crate file.
25
26           •  The original Cargo.toml file is rewritten and normalized.
27
28[patch], [replace], and [workspace] sections are removed from
29               the manifest.
30
31Cargo.lock is automatically included if the package contains an
32               executable binary or example target. cargo-install(1) will use
33               the packaged lock file if the --locked flag is used.
34
35           •  A .cargo_vcs_info.json file is included that contains
36               information about the current VCS checkout hash if available
37               (not included with --allow-dirty).
38
39        3. Extract the .crate file and build it to verify it can build.
40
41           •  This will rebuild your package from scratch to ensure that it
42               can be built from a pristine state. The --no-verify flag can be
43               used to skip this step.
44
45        4. Check that build scripts did not modify any source files.
46
47       The list of files included can be controlled with the include and
48       exclude fields in the manifest.
49
50       See the reference
51       <https://doc.rust-lang.org/cargo/reference/publishing.html> for more
52       details about packaging and publishing.
53

OPTIONS

55   Package Options
56       -l, --list
57           Print files included in a package without making one.
58
59       --no-verify
60           Don't verify the contents by building them.
61
62       --no-metadata
63           Ignore warnings about a lack of human-usable metadata (such as the
64           description or the license).
65
66       --allow-dirty
67           Allow working directories with uncommitted VCS changes to be
68           packaged.
69
70   Package Selection
71       By default, when no package selection options are given, the packages
72       selected depend on the selected manifest file (based on the current
73       working directory if --manifest-path is not given). If the manifest is
74       the root of a workspace then the workspaces default members are
75       selected, otherwise only the package defined by the manifest will be
76       selected.
77
78       The default members of a workspace can be set explicitly with the
79       workspace.default-members key in the root manifest. If this is not set,
80       a virtual workspace will include all workspace members (equivalent to
81       passing --workspace), and a non-virtual workspace will include only the
82       root crate itself.
83
84       -p spec..., --package spec...
85           Package only the specified packages. See cargo-pkgid(1) for the
86           SPEC format. This flag may be specified multiple times and supports
87           common Unix glob patterns like *, ? and []. However, to avoid your
88           shell accidentally expanding glob patterns before Cargo handles
89           them, you must use single quotes or double quotes around each
90           pattern.
91
92       --workspace
93           Package all members in the workspace.
94
95       --exclude SPEC...
96           Exclude the specified packages. Must be used in conjunction with
97           the --workspace flag. This flag may be specified multiple times and
98           supports common Unix glob patterns like *, ? and []. However, to
99           avoid your shell accidentally expanding glob patterns before Cargo
100           handles them, you must use single quotes or double quotes around
101           each pattern.
102
103   Compilation Options
104       --target triple
105           Package for the given architecture. The default is the host
106           architecture. The general format of the triple is
107           <arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for
108           a list of supported targets.
109
110           This may also be specified with the build.target config value
111           <https://doc.rust-lang.org/cargo/reference/config.html>.
112
113           Note that specifying this flag makes Cargo run in a different mode
114           where the target artifacts are placed in a separate directory. See
115           the build cache
116           <https://doc.rust-lang.org/cargo/guide/build-cache.html>
117           documentation for more details.
118
119       --target-dir directory
120           Directory for all generated artifacts and intermediate files. May
121           also be specified with the CARGO_TARGET_DIR environment variable,
122           or the build.target-dir config value
123           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
124           to target in the root of the workspace.
125
126   Feature Selection
127       The feature flags allow you to control which features are enabled. When
128       no feature options are given, the default feature is activated for
129       every selected package.
130
131       See the features documentation
132       <https://doc.rust-lang.org/cargo/reference/features.html#command-line-feature-options>
133       for more details.
134
135       --features features
136           Space or comma separated list of features to activate. Features of
137           workspace members may be enabled with package-name/feature-name
138           syntax. This flag may be specified multiple times, which enables
139           all specified features.
140
141       --all-features
142           Activate all available features of all selected packages.
143
144       --no-default-features
145           Do not activate the default feature of the selected packages.
146
147   Manifest Options
148       --manifest-path path
149           Path to the Cargo.toml file. By default, Cargo searches for the
150           Cargo.toml file in the current directory or any parent directory.
151
152       --frozen, --locked
153           Either of these flags requires that the Cargo.lock file is
154           up-to-date. If the lock file is missing, or it needs to be updated,
155           Cargo will exit with an error. The --frozen flag also prevents
156           Cargo from attempting to access the network to determine if it is
157           out-of-date.
158
159           These may be used in environments where you want to assert that the
160           Cargo.lock file is up-to-date (such as a CI build) or want to avoid
161           network access.
162
163       --offline
164           Prevents Cargo from accessing the network for any reason. Without
165           this flag, Cargo will stop with an error if it needs to access the
166           network and the network is not available. With this flag, Cargo
167           will attempt to proceed without the network if possible.
168
169           Beware that this may result in different dependency resolution than
170           online mode. Cargo will restrict itself to crates that are
171           downloaded locally, even if there might be a newer version as
172           indicated in the local copy of the index. See the cargo-fetch(1)
173           command to download dependencies before going offline.
174
175           May also be specified with the net.offline config value
176           <https://doc.rust-lang.org/cargo/reference/config.html>.
177
178   Miscellaneous Options
179       -j N, --jobs N
180           Number of parallel jobs to run. May also be specified with the
181           build.jobs config value
182           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
183           to the number of CPUs.
184
185   Display Options
186       -v, --verbose
187           Use verbose output. May be specified twice for "very verbose"
188           output which includes extra output such as dependency warnings and
189           build script output. May also be specified with the term.verbose
190           config value
191           <https://doc.rust-lang.org/cargo/reference/config.html>.
192
193       -q, --quiet
194           No output printed to stdout.
195
196       --color when
197           Control when colored output is used. Valid values:
198
199auto (default): Automatically detect if color support is
200               available on the terminal.
201
202always: Always display colors.
203
204never: Never display colors.
205
206           May also be specified with the term.color config value
207           <https://doc.rust-lang.org/cargo/reference/config.html>.
208
209   Common Options
210       +toolchain
211           If Cargo has been installed with rustup, and the first argument to
212           cargo begins with +, it will be interpreted as a rustup toolchain
213           name (such as +stable or +nightly). See the rustup documentation
214           <https://rust-lang.github.io/rustup/overrides.html> for more
215           information about how toolchain overrides work.
216
217       -h, --help
218           Prints help information.
219
220       -Z flag
221           Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
222           details.
223

ENVIRONMENT

225       See the reference
226       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
227       for details on environment variables that Cargo reads.
228

EXIT STATUS

2300: Cargo succeeded.
231
232101: Cargo failed to complete.
233

EXAMPLES

235        1. Create a compressed .crate file of the current package:
236
237               cargo package
238

SEE ALSO

240       cargo(1), cargo-publish(1)
241
242
243
244                                                              CARGO-PACKAGE(1)
Impressum