616 lines
16 KiB
HTML
616 lines
16 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of CARGO-INSTALL</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>CARGO-INSTALL</H1>
|
|
Section: (1)<BR>Updated: 2020-07-01<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
cargo-install - Build and install a Rust binary
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<P>
|
|
<B>cargo install [</B><I>OPTIONS</I>] <I>CRATE</I>...
|
|
<BR>
|
|
|
|
<B>cargo install [</B><I>OPTIONS</I>] --path <I>PATH</I>
|
|
<BR>
|
|
|
|
<B>cargo install [</B><I>OPTIONS</I>] --git <I>URL</I> [<I>CRATE</I>...]
|
|
<BR>
|
|
|
|
<B>cargo install [</B><I>OPTIONS</I>] --list
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
<P>
|
|
This command manages Cargo's local set of installed binary crates. Only
|
|
packages which have executable <B>[[bin]]</B> or <B>[[example]]</B> targets can be
|
|
installed, and all executables are installed into the installation root's
|
|
<B>bin</B> folder.
|
|
<P>
|
|
The installation root is determined, in order of precedence:
|
|
<P>
|
|
<DL COMPACT><DT id="1"><DD>
|
|
•
|
|
|
|
|
|
<B>--root</B> option
|
|
</DL>
|
|
|
|
<P>
|
|
<DL COMPACT><DT id="2"><DD>
|
|
•
|
|
|
|
|
|
<B>CARGO_INSTALL_ROOT</B> environment variable
|
|
</DL>
|
|
|
|
<P>
|
|
<DL COMPACT><DT id="3"><DD>
|
|
•
|
|
|
|
|
|
<B>install.root</B> Cargo
|
|
<I>config value</I> <<A HREF="https://doc.rust-lang.org/cargo/reference/config.html">https://doc.rust-lang.org/cargo/reference/config.html</A>>
|
|
|
|
</DL>
|
|
|
|
<P>
|
|
<DL COMPACT><DT id="4"><DD>
|
|
•
|
|
|
|
|
|
<B>CARGO_HOME</B> environment variable
|
|
</DL>
|
|
|
|
<P>
|
|
<DL COMPACT><DT id="5"><DD>
|
|
•
|
|
|
|
|
|
<B>$HOME/.cargo</B>
|
|
</DL>
|
|
|
|
<P>
|
|
There are multiple sources from which a crate can be installed. The default
|
|
location is crates.io but the <B>--git</B>, <B>--path</B>, and <B>--registry</B> flags can
|
|
change this source. If the source contains more than one package (such as
|
|
crates.io or a git repository with multiple crates) the <I>CRATE</I> argument is
|
|
required to indicate which crate should be installed.
|
|
<P>
|
|
Crates from crates.io can optionally specify the version they wish to install
|
|
via the <B>--version</B> flags, and similarly packages from git repositories can
|
|
optionally specify the branch, tag, or revision that should be installed. If a
|
|
crate has multiple binaries, the <B>--bin</B> argument can selectively install only
|
|
one of them, and if you'd rather install examples the <B>--example</B> argument can
|
|
be used as well.
|
|
<P>
|
|
If the package is already installed, Cargo will reinstall it if the installed
|
|
version does not appear to be up-to-date. If any of the following values
|
|
change, then Cargo will reinstall the package:
|
|
<P>
|
|
<DL COMPACT><DT id="6"><DD>
|
|
•
|
|
|
|
|
|
The package version and source.
|
|
</DL>
|
|
|
|
<P>
|
|
<DL COMPACT><DT id="7"><DD>
|
|
•
|
|
|
|
|
|
The set of binary names installed.
|
|
</DL>
|
|
|
|
<P>
|
|
<DL COMPACT><DT id="8"><DD>
|
|
•
|
|
|
|
|
|
The chosen features.
|
|
</DL>
|
|
|
|
<P>
|
|
<DL COMPACT><DT id="9"><DD>
|
|
•
|
|
|
|
|
|
The release mode (<B>--debug</B>).
|
|
</DL>
|
|
|
|
<P>
|
|
<DL COMPACT><DT id="10"><DD>
|
|
•
|
|
|
|
|
|
The target (<B>--target</B>).
|
|
</DL>
|
|
|
|
<P>
|
|
Installing with <B>--path</B> will always build and install, unless there are
|
|
conflicting binaries from another package. The <B>--force</B> flag may be used to
|
|
force Cargo to always reinstall the package.
|
|
<P>
|
|
If the source is crates.io or <B>--git</B> then by default the crate will be built
|
|
in a temporary target directory. To avoid this, the target directory can be
|
|
specified by setting the <B>CARGO_TARGET_DIR</B> environment variable to a relative
|
|
path. In particular, this can be useful for caching build artifacts on
|
|
continuous integration systems.
|
|
<P>
|
|
By default, the <B>Cargo.lock</B> file that is included with the package will be
|
|
ignored. This means that Cargo will recompute which versions of dependencies
|
|
to use, possibly using newer versions that have been released since the
|
|
package was published. The <B>--locked</B> flag can be used to force Cargo to use
|
|
the packaged <B>Cargo.lock</B> file if it is available. This may be useful for
|
|
ensuring reproducible builds, to use the exact same set of dependencies that
|
|
were available when the package was published. It may also be useful if a
|
|
newer version of a dependency is published that no longer builds on your
|
|
system, or has other problems. The downside to using <B>--locked</B> is that you
|
|
will not receive any fixes or updates to any dependency. Note that Cargo did
|
|
not start publishing <B>Cargo.lock</B> files until version 1.37, which means
|
|
packages published with prior versions will not have a <B>Cargo.lock</B> file
|
|
available.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>OPTIONS</H2>
|
|
|
|
<A NAME="lbAF"> </A>
|
|
<H3>Install Options</H3>
|
|
|
|
<P>
|
|
<B>--vers</B> <I>VERSION</I>, <B>--version</B> <I>VERSION</I>
|
|
<DL COMPACT><DT id="11"><DD>
|
|
Specify a version to install. This may be a
|
|
|
|
<I>version requirement</I> <<A HREF="https://doc.rust-lang.org/cargo/reference/specifying-dependencies.md">https://doc.rust-lang.org/cargo/reference/specifying-dependencies.md</A>>,
|
|
|
|
like
|
|
<B>~1.2</B>, to have Cargo select the newest version from the given
|
|
requirement. If the version does not have a requirement operator (such as
|
|
<B>^</B> or <B>~</B>), then it must be in the form <I>MAJOR.MINOR.PATCH</I>, and will
|
|
install exactly that version; it is <B>not</B> treated as a caret requirement
|
|
like Cargo dependencies are.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--git</B> <I>URL</I>
|
|
<DL COMPACT><DT id="12"><DD>
|
|
Git URL to install the specified crate from.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--branch</B> <I>BRANCH</I>
|
|
<DL COMPACT><DT id="13"><DD>
|
|
Branch to use when installing from git.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--tag</B> <I>TAG</I>
|
|
<DL COMPACT><DT id="14"><DD>
|
|
Tag to use when installing from git.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--rev</B> <I>SHA</I>
|
|
<DL COMPACT><DT id="15"><DD>
|
|
Specific commit to use when installing from git.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--path</B> <I>PATH</I>
|
|
<DL COMPACT><DT id="16"><DD>
|
|
Filesystem path to local crate to install.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--list</B>
|
|
<DL COMPACT><DT id="17"><DD>
|
|
List all installed packages and their versions.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>-f</B>, <B>--force</B>
|
|
<DL COMPACT><DT id="18"><DD>
|
|
Force overwriting existing crates or binaries. This can be used if a
|
|
package has installed a binary with the same name as another package. This
|
|
is also useful if something has changed on the system that you want to
|
|
rebuild with, such as a newer version of <B>rustc</B>.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--no-track</B>
|
|
<DL COMPACT><DT id="19"><DD>
|
|
By default, Cargo keeps track of the installed packages with a metadata
|
|
file stored in the installation root directory. This flag tells Cargo not
|
|
to use or create that file. With this flag, Cargo will refuse to overwrite
|
|
any existing files unless the <B>--force</B> flag is used. This also disables
|
|
Cargo's ability to protect against multiple concurrent invocations of
|
|
Cargo installing at the same time.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--bin</B> <I>NAME</I>...
|
|
<DL COMPACT><DT id="20"><DD>
|
|
Install only the specified binary.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--bins</B>
|
|
<DL COMPACT><DT id="21"><DD>
|
|
Install all binaries.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--example</B> <I>NAME</I>...
|
|
<DL COMPACT><DT id="22"><DD>
|
|
Install only the specified example.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--examples</B>
|
|
<DL COMPACT><DT id="23"><DD>
|
|
Install all examples.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--root</B> <I>DIR</I>
|
|
<DL COMPACT><DT id="24"><DD>
|
|
Directory to install packages into.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--registry</B> <I>REGISTRY</I>
|
|
<DL COMPACT><DT id="25"><DD>
|
|
Name of the registry to use. Registry names are defined in
|
|
<I>Cargo config files</I> <<A HREF="https://doc.rust-lang.org/cargo/reference/config.html">https://doc.rust-lang.org/cargo/reference/config.html</A>>.
|
|
|
|
If not specified, the default registry is used, which is defined by the
|
|
<B>registry.default</B> config key which defaults to <B>crates-io</B>.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--index</B> <I>INDEX</I>
|
|
<DL COMPACT><DT id="26"><DD>
|
|
The URL of the registry index to use.
|
|
</DL>
|
|
|
|
<A NAME="lbAG"> </A>
|
|
<H3>Feature Selection</H3>
|
|
|
|
<P>
|
|
The feature flags allow you to control the enabled features for the "current"
|
|
package. The "current" package is the package in the current directory, or the
|
|
one specified in <B>--manifest-path</B>. If running in the root of a virtual
|
|
workspace, then the default features are selected for all workspace members,
|
|
or all features if <B>--all-features</B> is specified.
|
|
<P>
|
|
When no feature options are given, the <B>default</B> feature is activated for
|
|
every selected package.
|
|
<P>
|
|
<B>--features</B> <I>FEATURES</I>
|
|
<DL COMPACT><DT id="27"><DD>
|
|
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 <B><dep-name>/<feature-name></B> syntax. This flag may be
|
|
specified multiple times, which enables all specified features.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--all-features</B>
|
|
<DL COMPACT><DT id="28"><DD>
|
|
Activate all available features of all selected packages.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--no-default-features</B>
|
|
<DL COMPACT><DT id="29"><DD>
|
|
Do not activate the <B>default</B> feature of the current directory's
|
|
package.
|
|
</DL>
|
|
|
|
<A NAME="lbAH"> </A>
|
|
<H3>Compilation Options</H3>
|
|
|
|
<P>
|
|
<B>--target</B> <I>TRIPLE</I>
|
|
<DL COMPACT><DT id="30"><DD>
|
|
Install for the given architecture. The default is the host
|
|
architecture. The general format of the triple is
|
|
<B><arch><sub>-<vendor>-<sys>-<abi></B>. Run <B>rustc --print target-list</B> for a
|
|
list of supported targets.
|
|
<P>
|
|
This may also be specified with the <B>build.target</B>
|
|
|
|
<I>config value</I> <<A HREF="https://doc.rust-lang.org/cargo/reference/config.html">https://doc.rust-lang.org/cargo/reference/config.html</A>>.
|
|
|
|
<P>
|
|
Note that specifying this flag makes Cargo run in a different mode where the
|
|
target artifacts are placed in a separate directory. See the
|
|
|
|
<I>build cache</I> <<A HREF="https://doc.rust-lang.org/cargo/guide/build-cache.html">https://doc.rust-lang.org/cargo/guide/build-cache.html</A>>
|
|
|
|
documentation for more details.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--target-dir</B> <I>DIRECTORY</I>
|
|
<DL COMPACT><DT id="31"><DD>
|
|
Directory for all generated artifacts and intermediate files. May also be
|
|
specified with the <B>CARGO_TARGET_DIR</B> environment variable, or the
|
|
<B>build.target-dir</B>
|
|
<I>config value</I> <<A HREF="https://doc.rust-lang.org/cargo/reference/config.html">https://doc.rust-lang.org/cargo/reference/config.html</A>>.
|
|
|
|
Defaults
|
|
to <B>target</B> in the root of the workspace.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--debug</B>
|
|
<DL COMPACT><DT id="32"><DD>
|
|
Build with the <B>dev</B> profile instead the <B>release</B> profile.
|
|
</DL>
|
|
|
|
<A NAME="lbAI"> </A>
|
|
<H3>Manifest Options</H3>
|
|
|
|
<P>
|
|
<B>--frozen</B>, <B>--locked</B>
|
|
<DL COMPACT><DT id="33"><DD>
|
|
Either of these flags requires that the <B>Cargo.lock</B> file is
|
|
up-to-date. If the lock file is missing, or it needs to be updated, Cargo will
|
|
exit with an error. The <B>--frozen</B> flag also prevents Cargo from
|
|
attempting to access the network to determine if it is out-of-date.
|
|
<P>
|
|
These may be used in environments where you want to assert that the
|
|
<B>Cargo.lock</B> file is up-to-date (such as a CI build) or want to avoid network
|
|
access.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--offline</B>
|
|
<DL COMPACT><DT id="34"><DD>
|
|
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>
|
|
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 <B><A HREF="/cgi-bin/man/man2html?1+cargo-fetch">cargo-fetch</A></B>(1) command to download dependencies before going
|
|
offline.
|
|
<P>
|
|
May also be specified with the <B>net.offline</B>
|
|
<I>config value</I> <<A HREF="https://doc.rust-lang.org/cargo/reference/config.html">https://doc.rust-lang.org/cargo/reference/config.html</A>>.
|
|
|
|
</DL>
|
|
|
|
<A NAME="lbAJ"> </A>
|
|
<H3>Miscellaneous Options</H3>
|
|
|
|
<P>
|
|
<B>-j</B> <I>N</I>, <B>--jobs</B> <I>N</I>
|
|
<DL COMPACT><DT id="35"><DD>
|
|
Number of parallel jobs to run. May also be specified with the
|
|
<B>build.jobs</B>
|
|
<I>config value</I> <<A HREF="https://doc.rust-lang.org/cargo/reference/config.html">https://doc.rust-lang.org/cargo/reference/config.html</A>>.
|
|
|
|
Defaults to
|
|
the number of CPUs.
|
|
</DL>
|
|
|
|
<A NAME="lbAK"> </A>
|
|
<H3>Display Options</H3>
|
|
|
|
<P>
|
|
<B>-v</B>, <B>--verbose</B>
|
|
<DL COMPACT><DT id="36"><DD>
|
|
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 <B>term.verbose</B>
|
|
|
|
<I>config value</I> <<A HREF="https://doc.rust-lang.org/cargo/reference/config.html">https://doc.rust-lang.org/cargo/reference/config.html</A>>.
|
|
|
|
</DL>
|
|
|
|
<P>
|
|
<B>-q</B>, <B>--quiet</B>
|
|
<DL COMPACT><DT id="37"><DD>
|
|
No output printed to stdout.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--color</B> <I>WHEN</I>
|
|
<DL COMPACT><DT id="38"><DD>
|
|
Control when colored output is used. Valid values:
|
|
<P>
|
|
<DL COMPACT><DT id="39"><DD>
|
|
•
|
|
|
|
|
|
<B>auto</B> (default): Automatically detect if color support is available on the
|
|
terminal.
|
|
</DL>
|
|
|
|
<P>
|
|
<DL COMPACT><DT id="40"><DD>
|
|
•
|
|
|
|
|
|
<B>always</B>: Always display colors.
|
|
</DL>
|
|
|
|
<P>
|
|
<DL COMPACT><DT id="41"><DD>
|
|
•
|
|
|
|
|
|
<B>never</B>: Never display colors.
|
|
</DL>
|
|
|
|
<P>
|
|
May also be specified with the <B>term.color</B>
|
|
|
|
<I>config value</I> <<A HREF="https://doc.rust-lang.org/cargo/reference/config.html">https://doc.rust-lang.org/cargo/reference/config.html</A>>.
|
|
|
|
</DL>
|
|
|
|
<A NAME="lbAL"> </A>
|
|
<H3>Common Options</H3>
|
|
|
|
<P>
|
|
<B>+TOOLCHAIN</B>
|
|
<DL COMPACT><DT id="42"><DD>
|
|
If Cargo has been installed with rustup, and the first argument to <B>cargo</B>
|
|
begins with <B>+</B>, it will be interpreted as a rustup toolchain name (such
|
|
as <B>+stable</B> or <B>+nightly</B>).
|
|
See the
|
|
<I>rustup documentation</I> <<A HREF="https://github.com/rust-lang/rustup/">https://github.com/rust-lang/rustup/</A>>
|
|
|
|
for more information about how toolchain overrides work.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>-h</B>, <B>--help</B>
|
|
<DL COMPACT><DT id="43"><DD>
|
|
Prints help information.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>-Z</B> <I>FLAG</I>...
|
|
<DL COMPACT><DT id="44"><DD>
|
|
Unstable (nightly-only) flags to Cargo. Run <B>cargo -Z help</B> for
|
|
details.
|
|
</DL>
|
|
|
|
<A NAME="lbAM"> </A>
|
|
<H2>ENVIRONMENT</H2>
|
|
|
|
<P>
|
|
See
|
|
<I>the reference</I> <<A HREF="https://doc.rust-lang.org/cargo/reference/environment-variables.html">https://doc.rust-lang.org/cargo/reference/environment-variables.html</A>>
|
|
|
|
for
|
|
details on environment variables that Cargo reads.
|
|
<A NAME="lbAN"> </A>
|
|
<H2>EXIT STATUS</H2>
|
|
|
|
<P>
|
|
0
|
|
<DL COMPACT><DT id="45"><DD>
|
|
Cargo succeeded.
|
|
</DL>
|
|
|
|
<P>
|
|
101
|
|
<DL COMPACT><DT id="46"><DD>
|
|
Cargo failed to complete.
|
|
</DL>
|
|
|
|
<A NAME="lbAO"> </A>
|
|
<H2>EXAMPLES</H2>
|
|
|
|
<P>
|
|
<DL COMPACT><DT id="47"><DD>
|
|
1.
|
|
|
|
|
|
Install or upgrade a package from crates.io:
|
|
<P>
|
|
<DL COMPACT><DT id="48"><DD>
|
|
|
|
<PRE>
|
|
cargo install ripgrep
|
|
</PRE>
|
|
|
|
</DL>
|
|
|
|
|
|
</DL>
|
|
|
|
<P>
|
|
<DL COMPACT><DT id="49"><DD>
|
|
2.
|
|
|
|
|
|
Install or reinstall the package in the current directory:
|
|
<P>
|
|
<DL COMPACT><DT id="50"><DD>
|
|
|
|
<PRE>
|
|
cargo install --path .
|
|
</PRE>
|
|
|
|
</DL>
|
|
|
|
|
|
</DL>
|
|
|
|
<P>
|
|
<DL COMPACT><DT id="51"><DD>
|
|
3.
|
|
|
|
|
|
View the list of installed packages:
|
|
<P>
|
|
<DL COMPACT><DT id="52"><DD>
|
|
|
|
<PRE>
|
|
cargo install --list
|
|
</PRE>
|
|
|
|
</DL>
|
|
|
|
|
|
</DL>
|
|
|
|
<A NAME="lbAP"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<P>
|
|
<B><A HREF="/cgi-bin/man/man2html?1+cargo">cargo</A></B>(1), <B><A HREF="/cgi-bin/man/man2html?1+cargo-uninstall">cargo-uninstall</A></B>(1), <B><A HREF="/cgi-bin/man/man2html?1+cargo-search">cargo-search</A></B>(1), <B><A HREF="/cgi-bin/man/man2html?1+cargo-publish">cargo-publish</A></B>(1)
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="53"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="54"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="55"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="56"><A HREF="#lbAE">OPTIONS</A><DD>
|
|
<DL>
|
|
<DT id="57"><A HREF="#lbAF">Install Options</A><DD>
|
|
<DT id="58"><A HREF="#lbAG">Feature Selection</A><DD>
|
|
<DT id="59"><A HREF="#lbAH">Compilation Options</A><DD>
|
|
<DT id="60"><A HREF="#lbAI">Manifest Options</A><DD>
|
|
<DT id="61"><A HREF="#lbAJ">Miscellaneous Options</A><DD>
|
|
<DT id="62"><A HREF="#lbAK">Display Options</A><DD>
|
|
<DT id="63"><A HREF="#lbAL">Common Options</A><DD>
|
|
</DL>
|
|
<DT id="64"><A HREF="#lbAM">ENVIRONMENT</A><DD>
|
|
<DT id="65"><A HREF="#lbAN">EXIT STATUS</A><DD>
|
|
<DT id="66"><A HREF="#lbAO">EXAMPLES</A><DD>
|
|
<DT id="67"><A HREF="#lbAP">SEE ALSO</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:08 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|