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

NAME

6       cargo-publish - Upload a package to the registry
7

SYNOPSIS

9       cargo publish [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 and upload it
14       to a registry. The default registry is <https://crates.io>. This
15       performs the following steps:
16
17        1. Performs a few checks, including:
18
19           •  Checks the package.publish key in the manifest for restrictions
20               on which registries you are allowed to publish to.
21
22        2. Create a .crate file by following the steps in cargo-package(1).
23
24        3. Upload the crate to the registry. Note that the server will perform
25           additional checks on the crate.
26
27       This command requires you to be authenticated with either the --token
28       option or using cargo-login(1).
29
30       See the reference
31       <https://doc.rust-lang.org/cargo/reference/publishing.html> for more
32       details about packaging and publishing.
33

OPTIONS

35   Publish Options
36       --dry-run
37           Perform all checks without uploading.
38
39       --token token
40           API token to use when authenticating. This overrides the token
41           stored in the credentials file (which is created by
42           cargo-login(1)).
43
44           Cargo config
45           <https://doc.rust-lang.org/cargo/reference/config.html> environment
46           variables can be used to override the tokens stored in the
47           credentials file. The token for crates.io may be specified with the
48           CARGO_REGISTRY_TOKEN environment variable. Tokens for other
49           registries may be specified with environment variables of the form
50           CARGO_REGISTRIES_NAME_TOKEN where NAME is the name of the registry
51           in all capital letters.
52
53       --no-verify
54           Don't verify the contents by building them.
55
56       --allow-dirty
57           Allow working directories with uncommitted VCS changes to be
58           packaged.
59
60       --index index
61           The URL of the registry index to use.
62
63       --registry registry
64           Name of the registry to publish to. Registry names are defined in
65           Cargo config files
66           <https://doc.rust-lang.org/cargo/reference/config.html>. If not
67           specified, and there is a package.publish
68           <https://doc.rust-lang.org/cargo/reference/manifest.html#the-publish-field>
69           field in Cargo.toml with a single registry, then it will publish to
70           that registry. Otherwise it will use the default registry, which is
71           defined by the registry.default
72           <https://doc.rust-lang.org/cargo/reference/config.html#registrydefault>
73           config key which defaults to crates-io.
74
75   Package Selection
76       By default, the package in the current working directory is selected.
77       The -p flag can be used to choose a different package in a workspace.
78
79       -p spec, --package spec
80           The package to publish. See cargo-pkgid(1) for the SPEC format.
81
82   Compilation Options
83       --target triple
84           Publish for the given architecture. The default is the host
85           architecture. The general format of the triple is
86           <arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for
87           a list of supported targets. This flag may be specified multiple
88           times.
89
90           This may also be specified with the build.target config value
91           <https://doc.rust-lang.org/cargo/reference/config.html>.
92
93           Note that specifying this flag makes Cargo run in a different mode
94           where the target artifacts are placed in a separate directory. See
95           the build cache
96           <https://doc.rust-lang.org/cargo/guide/build-cache.html>
97           documentation for more details.
98
99       --target-dir directory
100           Directory for all generated artifacts and intermediate files. May
101           also be specified with the CARGO_TARGET_DIR environment variable,
102           or the build.target-dir config value
103           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
104           to target in the root of the workspace.
105
106   Feature Selection
107       The feature flags allow you to control which features are enabled. When
108       no feature options are given, the default feature is activated for
109       every selected package.
110
111       See the features documentation
112       <https://doc.rust-lang.org/cargo/reference/features.html#command-line-feature-options>
113       for more details.
114
115       -F features, --features features
116           Space or comma separated list of features to activate. Features of
117           workspace members may be enabled with package-name/feature-name
118           syntax. This flag may be specified multiple times, which enables
119           all specified features.
120
121       --all-features
122           Activate all available features of all selected packages.
123
124       --no-default-features
125           Do not activate the default feature of the selected packages.
126
127   Manifest Options
128       --manifest-path path
129           Path to the Cargo.toml file. By default, Cargo searches for the
130           Cargo.toml file in the current directory or any parent directory.
131
132       --frozen, --locked
133           Either of these flags requires that the Cargo.lock file is
134           up-to-date. If the lock file is missing, or it needs to be updated,
135           Cargo will exit with an error. The --frozen flag also prevents
136           Cargo from attempting to access the network to determine if it is
137           out-of-date.
138
139           These may be used in environments where you want to assert that the
140           Cargo.lock file is up-to-date (such as a CI build) or want to avoid
141           network access.
142
143       --offline
144           Prevents Cargo from accessing the network for any reason. Without
145           this flag, Cargo will stop with an error if it needs to access the
146           network and the network is not available. With this flag, Cargo
147           will attempt to proceed without the network if possible.
148
149           Beware that this may result in different dependency resolution than
150           online mode. Cargo will restrict itself to crates that are
151           downloaded locally, even if there might be a newer version as
152           indicated in the local copy of the index. See the cargo-fetch(1)
153           command to download dependencies before going offline.
154
155           May also be specified with the net.offline config value
156           <https://doc.rust-lang.org/cargo/reference/config.html>.
157
158   Miscellaneous Options
159       -j N, --jobs N
160           Number of parallel jobs to run. May also be specified with the
161           build.jobs config value
162           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
163           to the number of logical CPUs. If negative, it sets the maximum
164           number of parallel jobs to the number of logical CPUs plus provided
165           value. Should not be 0.
166
167       --keep-going
168           Build as many crates in the dependency graph as possible, rather
169           than aborting the build on the first one that fails to build.
170           Unstable, requires -Zunstable-options.
171
172   Display Options
173       -v, --verbose
174           Use verbose output. May be specified twice for "very verbose"
175           output which includes extra output such as dependency warnings and
176           build script output. May also be specified with the term.verbose
177           config value
178           <https://doc.rust-lang.org/cargo/reference/config.html>.
179
180       -q, --quiet
181           Do not print cargo log messages. May also be specified with the
182           term.quiet config value
183           <https://doc.rust-lang.org/cargo/reference/config.html>.
184
185       --color when
186           Control when colored output is used. Valid values:
187
188auto (default): Automatically detect if color support is
189               available on the terminal.
190
191always: Always display colors.
192
193never: Never display colors.
194
195           May also be specified with the term.color config value
196           <https://doc.rust-lang.org/cargo/reference/config.html>.
197
198   Common Options
199       +toolchain
200           If Cargo has been installed with rustup, and the first argument to
201           cargo begins with +, it will be interpreted as a rustup toolchain
202           name (such as +stable or +nightly). See the rustup documentation
203           <https://rust-lang.github.io/rustup/overrides.html> for more
204           information about how toolchain overrides work.
205
206       --config KEY=VALUE or PATH
207           Overrides a Cargo configuration value. The argument should be in
208           TOML syntax of KEY=VALUE, or provided as a path to an extra
209           configuration file. This flag may be specified multiple times. See
210           the command-line overrides section
211           <https://doc.rust-lang.org/cargo/reference/config.html#command-line-overrides>
212           for more information.
213
214       -h, --help
215           Prints help information.
216
217       -Z flag
218           Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
219           details.
220

ENVIRONMENT

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

EXIT STATUS

2270: Cargo succeeded.
228
229101: Cargo failed to complete.
230

EXAMPLES

232        1. Publish the current package:
233
234               cargo publish
235

SEE ALSO

237       cargo(1), cargo-package(1), cargo-login(1)
238
239
240
241                                                              CARGO-PUBLISH(1)
Impressum