<h2 id="cargo_publish_name">NAME</h2>
<div class="sectionbody">
<p>cargo-publish - Upload a package to the registry</p>
</div>
<div class="sect1">
<h2 id="cargo_publish_synopsis">SYNOPSIS</h2>
<div class="sectionbody">
<div class="paragraph">
<p><code>cargo publish [<em>OPTIONS</em>]</code></p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="cargo_publish_description">DESCRIPTION</h2>
<div class="sectionbody">
<div class="paragraph">
<p>This command will create a distributable, compressed <code>.crate</code> file with the
source code of the package in the current directory and upload it to a
registry. The default registry is <a href="https://crates.io" class="bare">https://crates.io</a>. This performs the
following steps:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Performs a few checks, including:</p>
<div class="ulist">
<ul>
<li>
<p>Checks the <code>package.publish</code> key in the manifest for restrictions on which
registries you are allowed to publish to.</p>
</li>
</ul>
</div>
</li>
<li>
<p>Create a <code>.crate</code> file by following the steps in <a href="commands/cargo-package.html">cargo-package(1)</a>.</p>
</li>
<li>
<p>Upload the crate to the registry. Note that the server will perform
additional checks on the crate.</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>This command requires you to be authenticated with either the <code>--token</code> option
or using <a href="commands/cargo-login.html">cargo-login(1)</a>.</p>
</div>
<div class="paragraph">
<p>See <a href="reference/publishing.html">the reference</a> for more details about
packaging and publishing.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="cargo_publish_options">OPTIONS</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="cargo_publish_publish_options">Publish Options</h3>
<div class="dlist">
<dl>
<dt class="hdlist1"><strong>--dry-run</strong></dt>
<dd>
<p>Perform all checks without uploading.</p>
</dd>
<dt class="hdlist1"><strong>--token</strong> <em>TOKEN</em></dt>
<dd>
<p>API token to use when authenticating. This overrides the token stored in
the credentials file (which is created by <a href="commands/cargo-login.html">cargo-login(1)</a>).</p>
<div class="paragraph">
<p><a href="reference/config.html">Cargo config</a> environment variables can be
used to override the tokens stored in the credentials file. The token for
crates.io may be specified with the <code>CARGO_REGISTRY_TOKEN</code> environment
variable. Tokens for other registries may be specified with environment
variables of the form <code>CARGO_REGISTRIES_NAME_TOKEN</code> where <code>NAME</code> is the name
of the registry in all capital letters.</p>
</div>
</dd>
<dt class="hdlist1"><strong>--no-verify</strong></dt>
<dd>
<p>Don’t verify the contents by building them.</p>
</dd>
<dt class="hdlist1"><strong>--allow-dirty</strong></dt>
<dd>
<p>Allow working directories with uncommitted VCS changes to be packaged.</p>
</dd>
<dt class="hdlist1"><strong>--index</strong> <em>INDEX</em></dt>
<dd>
<p>The URL of the registry index to use.</p>
</dd>
<dt class="hdlist1"><strong>--registry</strong> <em>REGISTRY</em></dt>
<dd>
<p>Name of the registry to use. Registry names are defined in <a href="reference/config.html">Cargo config files</a>.
If not specified, the default registry is used, which is defined by the
<code>registry.default</code> config key which defaults to <code>crates-io</code>.</p>
</dd>
</dl>
</div>
</div>
<div class="sect2">
<h3 id="cargo_publish_compilation_options">Compilation Options</h3>
<div class="dlist">
<dl>
<dt class="hdlist1"><strong>--target</strong> <em>TRIPLE</em></dt>
<dd>
<p>Publish for the given architecture. The default is the host
architecture. The general format of the triple is
<code><arch><sub>-<vendor>-<sys>-<abi></code>. Run <code>rustc --print target-list</code> for a
list of supported targets.</p>
<div class="paragraph">
<p>This may also be specified with the <code>build.target</code>
<a href="reference/config.html">config value</a>.</p>
</div>
</dd>
<dt class="hdlist1"><strong>--target-dir</strong> <em>DIRECTORY</em></dt>
<dd>
<p>Directory for all generated artifacts and intermediate files. May also be
specified with the <code>CARGO_TARGET_DIR</code> environment variable, or the
<code>build.target-dir</code> <a href="reference/config.html">config value</a>. Defaults
to <code>target</code> in the root of the workspace.</p>
</dd>
</dl>
</div>
</div>
<div class="sect2">
<h3 id="cargo_publish_feature_selection">Feature Selection</h3>
<div class="paragraph">
<p>When no feature options are given, the <code>default</code> feature is activated for
every selected package.</p>
</div>
<div class="dlist">
<dl>
<dt class="hdlist1"><strong>--features</strong> <em>FEATURES</em></dt>
<dd>
<p>Space or comma separated list of features to activate. These features only
apply to the current directory’s package. Features of direct dependencies
may be enabled with <code><dep-name>/<feature-name></code> syntax.</p>
</dd>
<dt class="hdlist1"><strong>--all-features</strong></dt>
<dd>
<p>Activate all available features of all selected packages.</p>
</dd>
<dt class="hdlist1"><strong>--no-default-features</strong></dt>
<dd>
<p>Do not activate the <code>default</code> feature of the current directory’s
package.</p>
</dd>
</dl>
</div>
</div>
<div class="sect2">
<h3 id="cargo_publish_manifest_options">Manifest Options</h3>
<div class="dlist">
<dl>
<dt class="hdlist1"><strong>--manifest-path</strong> <em>PATH</em></dt>
<dd>
<p>Path to the <code>Cargo.toml</code> file. By default, Cargo searches in the current
directory or any parent directory for the <code>Cargo.toml</code> file.</p>
</dd>
<dt class="hdlist1"><strong>--frozen</strong></dt>
<dt class="hdlist1"><strong>--locked</strong></dt>
<dd>
<p>Either of these flags requires that the <code>Cargo.lock</code> file is
up-to-date. If the lock file is missing, or it needs to be updated, Cargo will
exit with an error. The <code>--frozen</code> flag also prevents Cargo from
attempting to access the network to determine if it is out-of-date.</p>
<div class="paragraph">
<p>These may be used in environments where you want to assert that the
<code>Cargo.lock</code> file is up-to-date (such as a CI build) or want to avoid network
access.</p>
</div>
</dd>
<dt class="hdlist1"><strong>--offline</strong></dt>
<dd>
<p>Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.</p>
<div class="paragraph">
<p>Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the <a href="commands/cargo-fetch.html">cargo-fetch(1)</a> command to download dependencies before going
offline.</p>
</div>
<div class="paragraph">
<p>May also be specified with the <code>net.offline</code> <a href="reference/config.html">config value</a>.</p>
</div>
</dd>
</dl>
</div>
</div>
<div class="sect2">
<h3 id="cargo_publish_miscellaneous_options">Miscellaneous Options</h3>
<div class="dlist">
<dl>
<dt class="hdlist1"><strong>-j</strong> <em>N</em></dt>
<dt class="hdlist1"><strong>--jobs</strong> <em>N</em></dt>
<dd>
<p>Number of parallel jobs to run. May also be specified with the
<code>build.jobs</code> <a href="reference/config.html">config value</a>. Defaults to
the number of CPUs.</p>
</dd>
</dl>
</div>
</div>
<div class="sect2">
<h3 id="cargo_publish_display_options">Display Options</h3>
<div class="dlist">
<dl>
<dt class="hdlist1"><strong>-v</strong></dt>
<dt class="hdlist1"><strong>--verbose</strong></dt>
<dd>
<p>Use verbose output. May be specified twice for "very verbose" output which
includes extra output such as dependency warnings and build script output.
May also be specified with the <code>term.verbose</code>
<a href="reference/config.html">config value</a>.</p>
</dd>
<dt class="hdlist1"><strong>-q</strong></dt>
<dt class="hdlist1"><strong>--quiet</strong></dt>
<dd>
<p>No output printed to stdout.</p>
</dd>
<dt class="hdlist1"><strong>--color</strong> <em>WHEN</em></dt>
<dd>
<p>Control when colored output is used. Valid values:</p>
<div class="ulist">
<ul>
<li>
<p><code>auto</code> (default): Automatically detect if color support is available on the
terminal.</p>
</li>
<li>
<p><code>always</code>: Always display colors.</p>
</li>
<li>
<p><code>never</code>: Never display colors.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>May also be specified with the <code>term.color</code>
<a href="reference/config.html">config value</a>.</p>
</div>
</dd>
</dl>
</div>
</div>
<div class="sect2">
<h3 id="cargo_publish_common_options">Common Options</h3>
<div class="dlist">
<dl>
<dt class="hdlist1"><strong>-h</strong></dt>
<dt class="hdlist1"><strong>--help</strong></dt>
<dd>
<p>Prints help information.</p>
</dd>
<dt class="hdlist1"><strong>-Z</strong> <em>FLAG</em>…​</dt>
<dd>
<p>Unstable (nightly-only) flags to Cargo. Run <code>cargo -Z help</code> for
details.</p>
</dd>
</dl>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="cargo_publish_environment">ENVIRONMENT</h2>
<div class="sectionbody">
<div class="paragraph">
<p>See <a href="reference/environment-variables.html">the reference</a> for
details on environment variables that Cargo reads.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="cargo_publish_exit_status">Exit Status</h2>
<div class="sectionbody">
<div class="dlist">
<dl>
<dt class="hdlist1">0</dt>
<dd>
<p>Cargo succeeded.</p>
</dd>
<dt class="hdlist1">101</dt>
<dd>
<p>Cargo failed to complete.</p>
</dd>
</dl>
</div>
</div>
</div>
<div class="sect1">
<h2 id="cargo_publish_examples">EXAMPLES</h2>
<div class="sectionbody">
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Publish the current package:</p>
<div class="literalblock">
<div class="content">
<pre>cargo publish</pre>
</div>
</div>
</li>
</ol>
</div>
</div>
</div>
<div class="sect1">
<h2 id="cargo_publish_see_also">SEE ALSO</h2>
<div class="sectionbody">
<div class="paragraph">
<p><a href="commands/index.html">cargo(1)</a>, <a href="commands/cargo-package.html">cargo-package(1)</a>, <a href="commands/cargo-login.html">cargo-login(1)</a></p>
</div>
</div>
</div>