1CARGO-INSTALL(1)                                              CARGO-INSTALL(1)
2
3
4

NAME

6       cargo-install - Build and install a Rust binary
7

SYNOPSIS

9       cargo install [OPTIONS] CRATE...
10       cargo install [OPTIONS] --path PATH
11       cargo install [OPTIONS] --git URL [CRATE...]
12       cargo install [OPTIONS] --list
13

DESCRIPTION

15       This command manages Cargo’s local set of installed binary crates. Only
16       packages which have executable [[bin]] or [[example]] targets can be
17       installed, and all executables are installed into the installation
18       root’s bin folder.
19
20       The installation root is determined, in order of precedence:
21
22       ·   --root option
23
24       ·   CARGO_INSTALL_ROOT environment variable
25
26       ·   install.root Cargo config value
27           <https://doc.rust-lang.org/cargo/reference/config.html>
28
29       ·   CARGO_HOME environment variable
30
31       ·   $HOME/.cargo
32
33       There are multiple sources from which a crate can be installed. The
34       default location is crates.io but the --git, --path, and --registry
35       flags can change this source. If the source contains more than one
36       package (such as crates.io or a git repository with multiple crates)
37       the CRATE argument is required to indicate which crate should be
38       installed.
39
40       Crates from crates.io can optionally specify the version they wish to
41       install via the --version flags, and similarly packages from git
42       repositories can optionally specify the branch, tag, or revision that
43       should be installed. If a crate has multiple binaries, the --bin
44       argument can selectively install only one of them, and if you’d rather
45       install examples the --example argument can be used as well.
46
47       If the package is already installed, Cargo will reinstall it if the
48       installed version does not appear to be up-to-date. If any of the
49       following values change, then Cargo will reinstall the package:
50
51       ·   The package version and source.
52
53       ·   The set of binary names installed.
54
55       ·   The chosen features.
56
57       ·   The release mode (--debug).
58
59       ·   The target (--target).
60
61       Installing with --path will always build and install, unless there are
62       conflicting binaries from another package. The --force flag may be used
63       to force Cargo to always reinstall the package.
64
65       If the source is crates.io or --git then by default the crate will be
66       built in a temporary target directory. To avoid this, the target
67       directory can be specified by setting the CARGO_TARGET_DIR environment
68       variable to a relative path. In particular, this can be useful for
69       caching build artifacts on continuous integration systems.
70
71       By default, the Cargo.lock file that is included with the package will
72       be ignored. This means that Cargo will recompute which versions of
73       dependencies to use, possibly using newer versions that have been
74       released since the package was published. The --locked flag can be used
75       to force Cargo to use the packaged Cargo.lock file if it is available.
76       This may be useful for ensuring reproducible builds, to use the exact
77       same set of dependencies that were available when the package was
78       published. It may also be useful if a newer version of a dependency is
79       published that no longer builds on your system, or has other problems.
80       The downside to using --locked is that you will not receive any fixes
81       or updates to any dependency. Note that Cargo did not start publishing
82       Cargo.lock files until version 1.37, which means packages published
83       with prior versions will not have a Cargo.lock file available.
84

OPTIONS

86   Install Options
87       --vers VERSION, --version VERSION
88           Specify a version to install. This may be a version requirement
89           <https://doc.rust-lang.org/cargo/reference/specifying-dependencies.md>,
90           like ~1.2, to have Cargo select the newest version from the given
91           requirement. If the version does not have a requirement operator
92           (such as ^ or ~), then it must be in the form MAJOR.MINOR.PATCH,
93           and will install exactly that version; it is not treated as a caret
94           requirement like Cargo dependencies are.
95
96       --git URL
97           Git URL to install the specified crate from.
98
99       --branch BRANCH
100           Branch to use when installing from git.
101
102       --tag TAG
103           Tag to use when installing from git.
104
105       --rev SHA
106           Specific commit to use when installing from git.
107
108       --path PATH
109           Filesystem path to local crate to install.
110
111       --list
112           List all installed packages and their versions.
113
114       -f, --force
115           Force overwriting existing crates or binaries. This can be used if
116           a package has installed a binary with the same name as another
117           package. This is also useful if something has changed on the system
118           that you want to rebuild with, such as a newer version of rustc.
119
120       --no-track
121           By default, Cargo keeps track of the installed packages with a
122           metadata file stored in the installation root directory. This flag
123           tells Cargo not to use or create that file. With this flag, Cargo
124           will refuse to overwrite any existing files unless the --force flag
125           is used. This also disables Cargo’s ability to protect against
126           multiple concurrent invocations of Cargo installing at the same
127           time.
128
129       --bin NAME...
130           Install only the specified binary.
131
132       --bins
133           Install all binaries.
134
135       --example NAME...
136           Install only the specified example.
137
138       --examples
139           Install all examples.
140
141       --root DIR
142           Directory to install packages into.
143
144       --registry REGISTRY
145           Name of the registry to use. Registry names are defined in Cargo
146           config files
147           <https://doc.rust-lang.org/cargo/reference/config.html>. If not
148           specified, the default registry is used, which is defined by the
149           registry.default config key which defaults to crates-io.
150
151   Feature Selection
152       The feature flags allow you to control the enabled features for the
153       "current" package. The "current" package is the package in the current
154       directory, or the one specified in --manifest-path. If running in the
155       root of a virtual workspace, then the default features are selected for
156       all workspace members, or all features if --all-features is specified.
157
158       When no feature options are given, the default feature is activated for
159       every selected package.
160
161       --features FEATURES
162           Space or comma separated list of features to activate. These
163           features only apply to the current directory’s package. Features of
164           direct dependencies may be enabled with <dep-name>/<feature-name>
165           syntax. This flag may be specified multiple times, which enables
166           all specified features.
167
168       --all-features
169           Activate all available features of all selected packages.
170
171       --no-default-features
172           Do not activate the default feature of the current directory’s
173           package.
174
175   Compilation Options
176       --target TRIPLE
177           Install for the given architecture. The default is the host
178           architecture. The general format of the triple is
179           <arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for
180           a list of supported targets.
181
182           This may also be specified with the build.target config value
183           <https://doc.rust-lang.org/cargo/reference/config.html>.
184
185           Note that specifying this flag makes Cargo run in a different mode
186           where the target artifacts are placed in a separate directory. See
187           the build cache
188           <https://doc.rust-lang.org/cargo/guide/build-cache.html>
189           documentation for more details.
190
191       --debug
192           Build with the dev profile instead the release profile.
193
194   Manifest Options
195       --frozen, --locked
196           Either of these flags requires that the Cargo.lock file is
197           up-to-date. If the lock file is missing, or it needs to be updated,
198           Cargo will exit with an error. The --frozen flag also prevents
199           Cargo from attempting to access the network to determine if it is
200           out-of-date.
201
202           These may be used in environments where you want to assert that the
203           Cargo.lock file is up-to-date (such as a CI build) or want to avoid
204           network access.
205
206       --offline
207           Prevents Cargo from accessing the network for any reason. Without
208           this flag, Cargo will stop with an error if it needs to access the
209           network and the network is not available. With this flag, Cargo
210           will attempt to proceed without the network if possible.
211
212           Beware that this may result in different dependency resolution than
213           online mode. Cargo will restrict itself to crates that are
214           downloaded locally, even if there might be a newer version as
215           indicated in the local copy of the index. See the cargo-fetch(1)
216           command to download dependencies before going offline.
217
218           May also be specified with the net.offline config value
219           <https://doc.rust-lang.org/cargo/reference/config.html>.
220
221   Miscellaneous Options
222       -j N, --jobs N
223           Number of parallel jobs to run. May also be specified with the
224           build.jobs config value
225           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
226           to the number of CPUs.
227
228   Display Options
229       -v, --verbose
230           Use verbose output. May be specified twice for "very verbose"
231           output which includes extra output such as dependency warnings and
232           build script output. May also be specified with the term.verbose
233           config value
234           <https://doc.rust-lang.org/cargo/reference/config.html>.
235
236       -q, --quiet
237           No output printed to stdout.
238
239       --color WHEN
240           Control when colored output is used. Valid values:
241
242           ·   auto (default): Automatically detect if color support is
243               available on the terminal.
244
245           ·   always: Always display colors.
246
247           ·   never: Never display colors.
248
249           May also be specified with the term.color config value
250           <https://doc.rust-lang.org/cargo/reference/config.html>.
251
252   Common Options
253       -h, --help
254           Prints help information.
255
256       -Z FLAG...
257           Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
258           details.
259

ENVIRONMENT

261       See the reference
262       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
263       for details on environment variables that Cargo reads.
264

EXIT STATUS

266       0
267           Cargo succeeded.
268
269       101
270           Cargo failed to complete.
271

EXAMPLES

273        1. Install or upgrade a package from crates.io:
274
275               cargo install ripgrep
276
277        2. Install or reinstall the package in the current directory:
278
279               cargo install --path .
280
281        3. View the list of installed packages:
282
283               cargo install --list
284

SEE ALSO

286       cargo(1), cargo-uninstall(1), cargo-search(1), cargo-publish(1)
287
288
289
290                                  2020-02-06                  CARGO-INSTALL(1)
Impressum