<h2 id="_name">NAME</h2>
<div class="sectionbody">
<p>cargo - The Rust package manager</p>
</div>
<div class="sect1">
<h2 id="_synopsis">SYNOPSIS</h2>
<div class="sectionbody">
<div class="paragraph">
<p><code>cargo [<em>OPTIONS</em>] <em>COMMAND</em> [<em>ARGS</em>]</code><br>
<code>cargo [<em>OPTIONS</em>] --version</code><br>
<code>cargo [<em>OPTIONS</em>] --list</code><br>
<code>cargo [<em>OPTIONS</em>] --help</code><br>
<code>cargo [<em>OPTIONS</em>] --explain <em>CODE</em></code></p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_description">DESCRIPTION</h2>
<div class="sectionbody">
<div class="paragraph">
<p>This program is a package manager and build tool for the Rust language,
available at <a href="https://rust-lang.org" class="bare">https://rust-lang.org</a>.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_commands">COMMANDS</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_build_commands">Build Commands</h3>
<div class="dlist">
<dl>
<dt class="hdlist1"><a href="commands/cargo-bench.html">cargo-bench(1)</a></dt>
<dd>
<p>Execute benchmarks of a package.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-build.html">cargo-build(1)</a></dt>
<dd>
<p>Compile a package.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-check.html">cargo-check(1)</a></dt>
<dd>
<p>Check a local package and all of its dependencies for errors.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-clean.html">cargo-clean(1)</a></dt>
<dd>
<p>Remove artifacts that Cargo has generated in the past.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-doc.html">cargo-doc(1)</a></dt>
<dd>
<p>Build a package’s documentation.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-fetch.html">cargo-fetch(1)</a></dt>
<dd>
<p>Fetch dependencies of a package from the network.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-fix.html">cargo-fix(1)</a></dt>
<dd>
<p>Automatically fix lint warnings reported by rustc.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-run.html">cargo-run(1)</a></dt>
<dd>
<p>Run a binary or example of the local package.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-rustc.html">cargo-rustc(1)</a></dt>
<dd>
<p>Compile a package, and pass extra options to the compiler.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-rustdoc.html">cargo-rustdoc(1)</a></dt>
<dd>
<p>Build a package’s documentation, using specified custom flags.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-test.html">cargo-test(1)</a></dt>
<dd>
<p>Execute unit and integration tests of a package.</p>
</dd>
</dl>
</div>
</div>
<div class="sect2">
<h3 id="_manifest_commands">Manifest Commands</h3>
<div class="dlist">
<dl>
<dt class="hdlist1"><a href="commands/cargo-generate-lockfile.html">cargo-generate-lockfile(1)</a></dt>
<dd>
<p>Generate <code>Cargo.lock</code> for a project.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-locate-project.html">cargo-locate-project(1)</a></dt>
<dd>
<p>Print a JSON representation of a <code>Cargo.toml</code> file’s location.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-metadata.html">cargo-metadata(1)</a></dt>
<dd>
<p>Output the resolved dependencies of a package, the concrete used versions
including overrides, in machine-readable format.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-pkgid.html">cargo-pkgid(1)</a></dt>
<dd>
<p>Print a fully qualified package specification.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-update.html">cargo-update(1)</a></dt>
<dd>
<p>Update dependencies as recorded in the local lock file.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-verify-project.html">cargo-verify-project(1)</a></dt>
<dd>
<p>Check correctness of crate manifest.</p>
</dd>
</dl>
</div>
</div>
<div class="sect2">
<h3 id="_package_commands">Package Commands</h3>
<div class="dlist">
<dl>
<dt class="hdlist1"><a href="commands/cargo-init.html">cargo-init(1)</a></dt>
<dd>
<p>Create a new Cargo package in an existing directory.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-install.html">cargo-install(1)</a></dt>
<dd>
<p>Build and install a Rust binary.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-new.html">cargo-new(1)</a></dt>
<dd>
<p>Create a new Cargo package.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-search.html">cargo-search(1)</a></dt>
<dd>
<p>Search packages in crates.io.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-uninstall.html">cargo-uninstall(1)</a></dt>
<dd>
<p>Remove a Rust binary.</p>
</dd>
</dl>
</div>
</div>
<div class="sect2">
<h3 id="_publishing_commands">Publishing Commands</h3>
<div class="dlist">
<dl>
<dt class="hdlist1"><a href="commands/cargo-login.html">cargo-login(1)</a></dt>
<dd>
<p>Save an API token from the registry locally.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-owner.html">cargo-owner(1)</a></dt>
<dd>
<p>Manage the owners of a crate on the registry.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-package.html">cargo-package(1)</a></dt>
<dd>
<p>Assemble the local package into a distributable tarball.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-publish.html">cargo-publish(1)</a></dt>
<dd>
<p>Upload a package to the registry.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-yank.html">cargo-yank(1)</a></dt>
<dd>
<p>Remove a pushed crate from the index.</p>
</dd>
</dl>
</div>
</div>
<div class="sect2">
<h3 id="_general_commands">General Commands</h3>
<div class="dlist">
<dl>
<dt class="hdlist1"><a href="commands/cargo-help.html">cargo-help(1)</a></dt>
<dd>
<p>Display help information about Cargo.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-version.html">cargo-version(1)</a></dt>
<dd>
<p>Show version information.</p>
</dd>
</dl>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_options">OPTIONS</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_special_options">Special Options</h3>
<div class="dlist">
<dl>
<dt class="hdlist1"><strong>-V</strong></dt>
<dt class="hdlist1"><strong>--version</strong></dt>
<dd>
<p>Print version info and exit. If used with <code>--verbose</code>, prints extra
information.</p>
</dd>
<dt class="hdlist1"><strong>--list</strong></dt>
<dd>
<p>List all installed Cargo subcommands. If used with <code>--verbose</code>, prints
extra information.</p>
</dd>
<dt class="hdlist1"><strong>--explain <em>CODE</em></strong></dt>
<dd>
<p>Run <code>rustc --explain CODE</code> which will print out a detailed explanation of
an error message (for example, <code>E0004</code>).</p>
</dd>
</dl>
</div>
</div>
<div class="sect2">
<h3 id="_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="_manifest_options">Manifest Options</h3>
<div class="dlist">
<dl>
<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="_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="_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="_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="_files">FILES</h2>
<div class="sectionbody">
<div class="dlist">
<dl>
<dt class="hdlist1"><code>~/.cargo/</code></dt>
<dd>
<p>Default location for Cargo’s "home" directory where it stores various
files. The location can be changed with the <code>CARGO_HOME</code> environment
variable.</p>
</dd>
<dt class="hdlist1"><code>$CARGO_HOME/bin/</code></dt>
<dd>
<p>Binaries installed by <a href="commands/cargo-install.html">cargo-install(1)</a> will be located here. If using
rustup, executables distributed with Rust are also located here.</p>
</dd>
<dt class="hdlist1"><code>$CARGO_HOME/config</code></dt>
<dd>
<p>The global configuration file. See <a href="reference/config.html">the reference</a>
for more information about configuration files.</p>
</dd>
<dt class="hdlist1"><code>.cargo/config</code></dt>
<dd>
<p>Cargo automatically searches for a file named <code>.cargo/config</code> in the
current directory, and all parent directories. These configuration files
will be merged with the global configuration file.</p>
</dd>
<dt class="hdlist1"><code>$CARGO_HOME/credentials</code></dt>
<dd>
<p>Private authentication information for logging in to a registry.</p>
</dd>
<dt class="hdlist1"><code>$CARGO_HOME/registry/</code></dt>
<dd>
<p>This directory contains cached downloads of the registry index and any
downloaded dependencies.</p>
</dd>
<dt class="hdlist1"><code>$CARGO_HOME/git/</code></dt>
<dd>
<p>This directory contains cached downloads of git dependencies.</p>
</dd>
</dl>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_examples">EXAMPLES</h2>
<div class="sectionbody">
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Build a local package and all of its dependencies:</p>
<div class="literalblock">
<div class="content">
<pre>cargo build</pre>
</div>
</div>
</li>
<li>
<p>Build a package with optimizations:</p>
<div class="literalblock">
<div class="content">
<pre>cargo build --release</pre>
</div>
</div>
</li>
<li>
<p>Run tests for a cross-compiled target:</p>
<div class="literalblock">
<div class="content">
<pre>cargo test --target i686-unknown-linux-gnu</pre>
</div>
</div>
</li>
<li>
<p>Create a new package that builds an executable:</p>
<div class="literalblock">
<div class="content">
<pre>cargo new foobar</pre>
</div>
</div>
</li>
<li>
<p>Create a package in the current directory:</p>
<div class="literalblock">
<div class="content">
<pre>mkdir foo && cd foo
cargo init .</pre>
</div>
</div>
</li>
<li>
<p>Learn about a command’s options and usage:</p>
<div class="literalblock">
<div class="content">
<pre>cargo help clean</pre>
</div>
</div>
</li>
</ol>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_bugs">BUGS</h2>
<div class="sectionbody">
<div class="paragraph">
<p>See <a href="https://github.com/rust-lang/cargo/issues" class="bare">https://github.com/rust-lang/cargo/issues</a> for issues.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_see_also">SEE ALSO</h2>
<div class="sectionbody">
<div class="paragraph">
<p><a href="https://doc.rust-lang.org/rustc/index.html">rustc(1)</a>, <a href="https://doc.rust-lang.org/rustdoc/index.html">rustdoc(1)</a></p>
</div>
</div>
</div>