1CARGO-PACKAGE(1) General Commands Manual CARGO-PACKAGE(1)
2
3
4
6 cargo-package - Assemble the local package into a distributable tarball
7
9 cargo package [options]
10
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
31 • Cargo.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
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 Compilation Options
71 --target triple
72 Package for the given architecture. The default is the host
73 architecture. The general format of the triple is
74 <arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for
75 a list of supported targets.
76
77 This may also be specified with the build.target config value
78 <https://doc.rust-lang.org/cargo/reference/config.html>.
79
80 Note that specifying this flag makes Cargo run in a different mode
81 where the target artifacts are placed in a separate directory. See
82 the build cache
83 <https://doc.rust-lang.org/cargo/guide/build-cache.html>
84 documentation for more details.
85
86 --target-dir directory
87 Directory for all generated artifacts and intermediate files. May
88 also be specified with the CARGO_TARGET_DIR environment variable,
89 or the build.target-dir config value
90 <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
91 to target in the root of the workspace.
92
93 Feature Selection
94 The feature flags allow you to control which features are enabled. When
95 no feature options are given, the default feature is activated for
96 every selected package.
97
98 See the features documentation
99 <https://doc.rust-lang.org/cargo/reference/features.html#command-line-feature-options>
100 for more details.
101
102 --features features
103 Space or comma separated list of features to activate. Features of
104 workspace members may be enabled with package-name/feature-name
105 syntax. This flag may be specified multiple times, which enables
106 all specified features.
107
108 --all-features
109 Activate all available features of all selected packages.
110
111 --no-default-features
112 Do not activate the default feature of the selected packages.
113
114 Manifest Options
115 --manifest-path path
116 Path to the Cargo.toml file. By default, Cargo searches for the
117 Cargo.toml file in the current directory or any parent directory.
118
119 --frozen, --locked
120 Either of these flags requires that the Cargo.lock file is
121 up-to-date. If the lock file is missing, or it needs to be updated,
122 Cargo will exit with an error. The --frozen flag also prevents
123 Cargo from attempting to access the network to determine if it is
124 out-of-date.
125
126 These may be used in environments where you want to assert that the
127 Cargo.lock file is up-to-date (such as a CI build) or want to avoid
128 network access.
129
130 --offline
131 Prevents Cargo from accessing the network for any reason. Without
132 this flag, Cargo will stop with an error if it needs to access the
133 network and the network is not available. With this flag, Cargo
134 will attempt to proceed without the network if possible.
135
136 Beware that this may result in different dependency resolution than
137 online mode. Cargo will restrict itself to crates that are
138 downloaded locally, even if there might be a newer version as
139 indicated in the local copy of the index. See the cargo-fetch(1)
140 command to download dependencies before going offline.
141
142 May also be specified with the net.offline config value
143 <https://doc.rust-lang.org/cargo/reference/config.html>.
144
145 Miscellaneous Options
146 -j N, --jobs N
147 Number of parallel jobs to run. May also be specified with the
148 build.jobs config value
149 <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
150 to the number of CPUs.
151
152 Display Options
153 -v, --verbose
154 Use verbose output. May be specified twice for "very verbose"
155 output which includes extra output such as dependency warnings and
156 build script output. May also be specified with the term.verbose
157 config value
158 <https://doc.rust-lang.org/cargo/reference/config.html>.
159
160 -q, --quiet
161 No output printed to stdout.
162
163 --color when
164 Control when colored output is used. Valid values:
165
166 • auto (default): Automatically detect if color support is
167 available on the terminal.
168
169 • always: Always display colors.
170
171 • never: Never display colors.
172
173 May also be specified with the term.color config value
174 <https://doc.rust-lang.org/cargo/reference/config.html>.
175
176 Common Options
177 +toolchain
178 If Cargo has been installed with rustup, and the first argument to
179 cargo begins with +, it will be interpreted as a rustup toolchain
180 name (such as +stable or +nightly). See the rustup documentation
181 <https://rust-lang.github.io/rustup/overrides.html> for more
182 information about how toolchain overrides work.
183
184 -h, --help
185 Prints help information.
186
187 -Z flag
188 Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
189 details.
190
192 See the reference
193 <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
194 for details on environment variables that Cargo reads.
195
197 • 0: Cargo succeeded.
198
199 • 101: Cargo failed to complete.
200
202 1. Create a compressed .crate file of the current package:
203
204 cargo package
205
207 cargo(1), cargo-publish(1)
208
209
210
211 CARGO-PACKAGE(1)