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

ENVIRONMENT

211       See the reference
212       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
213       for details on environment variables that Cargo reads.
214

EXIT STATUS

2160: Cargo succeeded.
217
218101: Cargo failed to complete.
219

EXAMPLES

221        1. Publish the current package:
222
223               cargo publish
224

SEE ALSO

226       cargo(1), cargo-package(1), cargo-login(1)
227
228
229
230                                                              CARGO-PUBLISH(1)
Impressum