blob: 7501ddef2f526d2c556aa0970517ea8966c271f2 [file] [log] [blame]
Jeff Vander Stoep956d1432020-09-18 13:46:24 +02001'\" t
2.\" Title: cargo-install
3.\" Author: [see the "AUTHOR(S)" section]
4.\" Generator: Asciidoctor 2.0.10
5.\" Date: 2020-07-01
6.\" Manual: \ \&
7.\" Source: \ \&
8.\" Language: English
9.\"
10.TH "CARGO\-INSTALL" "1" "2020-07-01" "\ \&" "\ \&"
11.ie \n(.g .ds Aq \(aq
12.el .ds Aq '
13.ss \n[.ss] 0
14.nh
15.ad l
16.de URL
17\fI\\$2\fP <\\$1>\\$3
18..
19.als MTO URL
20.if \n[.g] \{\
21. mso www.tmac
22. am URL
23. ad l
24. .
25. am MTO
26. ad l
27. .
28. LINKSTYLE blue R < >
29.\}
30.SH "NAME"
31cargo\-install \- Build and install a Rust binary
32.SH "SYNOPSIS"
33.sp
34\fBcargo install [\fIOPTIONS\fP] \fICRATE\fP...\fP
35.br
36\fBcargo install [\fIOPTIONS\fP] \-\-path \fIPATH\fP\fP
37.br
38\fBcargo install [\fIOPTIONS\fP] \-\-git \fIURL\fP [\fICRATE\fP...]\fP
39.br
40\fBcargo install [\fIOPTIONS\fP] \-\-list\fP
41.SH "DESCRIPTION"
42.sp
43This command manages Cargo\(cqs local set of installed binary crates. Only
44packages which have executable \fB[[bin]]\fP or \fB[[example]]\fP targets can be
45installed, and all executables are installed into the installation root\(cqs
46\fBbin\fP folder.
47.sp
48The installation root is determined, in order of precedence:
49.sp
50.RS 4
51.ie n \{\
52\h'-04'\(bu\h'+03'\c
53.\}
54.el \{\
55. sp -1
56. IP \(bu 2.3
57.\}
58\fB\-\-root\fP option
59.RE
60.sp
61.RS 4
62.ie n \{\
63\h'-04'\(bu\h'+03'\c
64.\}
65.el \{\
66. sp -1
67. IP \(bu 2.3
68.\}
69\fBCARGO_INSTALL_ROOT\fP environment variable
70.RE
71.sp
72.RS 4
73.ie n \{\
74\h'-04'\(bu\h'+03'\c
75.\}
76.el \{\
77. sp -1
78. IP \(bu 2.3
79.\}
80\fBinstall.root\fP Cargo \c
81.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" ""
82.RE
83.sp
84.RS 4
85.ie n \{\
86\h'-04'\(bu\h'+03'\c
87.\}
88.el \{\
89. sp -1
90. IP \(bu 2.3
91.\}
92\fBCARGO_HOME\fP environment variable
93.RE
94.sp
95.RS 4
96.ie n \{\
97\h'-04'\(bu\h'+03'\c
98.\}
99.el \{\
100. sp -1
101. IP \(bu 2.3
102.\}
103\fB$HOME/.cargo\fP
104.RE
105.sp
106There are multiple sources from which a crate can be installed. The default
107location is crates.io but the \fB\-\-git\fP, \fB\-\-path\fP, and \fB\-\-registry\fP flags can
108change this source. If the source contains more than one package (such as
109crates.io or a git repository with multiple crates) the \fICRATE\fP argument is
110required to indicate which crate should be installed.
111.sp
112Crates from crates.io can optionally specify the version they wish to install
113via the \fB\-\-version\fP flags, and similarly packages from git repositories can
114optionally specify the branch, tag, or revision that should be installed. If a
115crate has multiple binaries, the \fB\-\-bin\fP argument can selectively install only
116one of them, and if you\(cqd rather install examples the \fB\-\-example\fP argument can
117be used as well.
118.sp
119If the package is already installed, Cargo will reinstall it if the installed
120version does not appear to be up\-to\-date. If any of the following values
121change, then Cargo will reinstall the package:
122.sp
123.RS 4
124.ie n \{\
125\h'-04'\(bu\h'+03'\c
126.\}
127.el \{\
128. sp -1
129. IP \(bu 2.3
130.\}
131The package version and source.
132.RE
133.sp
134.RS 4
135.ie n \{\
136\h'-04'\(bu\h'+03'\c
137.\}
138.el \{\
139. sp -1
140. IP \(bu 2.3
141.\}
142The set of binary names installed.
143.RE
144.sp
145.RS 4
146.ie n \{\
147\h'-04'\(bu\h'+03'\c
148.\}
149.el \{\
150. sp -1
151. IP \(bu 2.3
152.\}
153The chosen features.
154.RE
155.sp
156.RS 4
157.ie n \{\
158\h'-04'\(bu\h'+03'\c
159.\}
160.el \{\
161. sp -1
162. IP \(bu 2.3
163.\}
164The release mode (\fB\-\-debug\fP).
165.RE
166.sp
167.RS 4
168.ie n \{\
169\h'-04'\(bu\h'+03'\c
170.\}
171.el \{\
172. sp -1
173. IP \(bu 2.3
174.\}
175The target (\fB\-\-target\fP).
176.RE
177.sp
178Installing with \fB\-\-path\fP will always build and install, unless there are
179conflicting binaries from another package. The \fB\-\-force\fP flag may be used to
180force Cargo to always reinstall the package.
181.sp
182If the source is crates.io or \fB\-\-git\fP then by default the crate will be built
183in a temporary target directory. To avoid this, the target directory can be
184specified by setting the \fBCARGO_TARGET_DIR\fP environment variable to a relative
185path. In particular, this can be useful for caching build artifacts on
186continuous integration systems.
187.sp
188By default, the \fBCargo.lock\fP file that is included with the package will be
189ignored. This means that Cargo will recompute which versions of dependencies
190to use, possibly using newer versions that have been released since the
191package was published. The \fB\-\-locked\fP flag can be used to force Cargo to use
192the packaged \fBCargo.lock\fP file if it is available. This may be useful for
193ensuring reproducible builds, to use the exact same set of dependencies that
194were available when the package was published. It may also be useful if a
195newer version of a dependency is published that no longer builds on your
196system, or has other problems. The downside to using \fB\-\-locked\fP is that you
197will not receive any fixes or updates to any dependency. Note that Cargo did
198not start publishing \fBCargo.lock\fP files until version 1.37, which means
199packages published with prior versions will not have a \fBCargo.lock\fP file
200available.
201.SH "OPTIONS"
202.SS "Install Options"
203.sp
204\fB\-\-vers\fP \fIVERSION\fP, \fB\-\-version\fP \fIVERSION\fP
205.RS 4
206Specify a version to install. This may be a
207.URL "https://doc.rust\-lang.org/cargo/reference/specifying\-dependencies.md" "version requirement" ","
208like
209\fB~1.2\fP, to have Cargo select the newest version from the given
210requirement. If the version does not have a requirement operator (such as
211\fB^\fP or \fB~\fP), then it must be in the form \fIMAJOR.MINOR.PATCH\fP, and will
212install exactly that version; it is \fBnot\fP treated as a caret requirement
213like Cargo dependencies are.
214.RE
215.sp
216\fB\-\-git\fP \fIURL\fP
217.RS 4
218Git URL to install the specified crate from.
219.RE
220.sp
221\fB\-\-branch\fP \fIBRANCH\fP
222.RS 4
223Branch to use when installing from git.
224.RE
225.sp
226\fB\-\-tag\fP \fITAG\fP
227.RS 4
228Tag to use when installing from git.
229.RE
230.sp
231\fB\-\-rev\fP \fISHA\fP
232.RS 4
233Specific commit to use when installing from git.
234.RE
235.sp
236\fB\-\-path\fP \fIPATH\fP
237.RS 4
238Filesystem path to local crate to install.
239.RE
240.sp
241\fB\-\-list\fP
242.RS 4
243List all installed packages and their versions.
244.RE
245.sp
246\fB\-f\fP, \fB\-\-force\fP
247.RS 4
248Force overwriting existing crates or binaries. This can be used if a
249package has installed a binary with the same name as another package. This
250is also useful if something has changed on the system that you want to
251rebuild with, such as a newer version of \fBrustc\fP.
252.RE
253.sp
254\fB\-\-no\-track\fP
255.RS 4
256By default, Cargo keeps track of the installed packages with a metadata
257file stored in the installation root directory. This flag tells Cargo not
258to use or create that file. With this flag, Cargo will refuse to overwrite
259any existing files unless the \fB\-\-force\fP flag is used. This also disables
260Cargo\(cqs ability to protect against multiple concurrent invocations of
261Cargo installing at the same time.
262.RE
263.sp
264\fB\-\-bin\fP \fINAME\fP...
265.RS 4
266Install only the specified binary.
267.RE
268.sp
269\fB\-\-bins\fP
270.RS 4
271Install all binaries.
272.RE
273.sp
274\fB\-\-example\fP \fINAME\fP...
275.RS 4
276Install only the specified example.
277.RE
278.sp
279\fB\-\-examples\fP
280.RS 4
281Install all examples.
282.RE
283.sp
284\fB\-\-root\fP \fIDIR\fP
285.RS 4
286Directory to install packages into.
287.RE
288.sp
289\fB\-\-registry\fP \fIREGISTRY\fP
290.RS 4
291Name of the registry to use. Registry names are defined in \c
292.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "Cargo config files" "."
293If not specified, the default registry is used, which is defined by the
294\fBregistry.default\fP config key which defaults to \fBcrates\-io\fP.
295.RE
296.sp
297\fB\-\-index\fP \fIINDEX\fP
298.RS 4
299The URL of the registry index to use.
300.RE
301.SS "Feature Selection"
302.sp
303The feature flags allow you to control the enabled features for the "current"
304package. The "current" package is the package in the current directory, or the
305one specified in \fB\-\-manifest\-path\fP. If running in the root of a virtual
306workspace, then the default features are selected for all workspace members,
307or all features if \fB\-\-all\-features\fP is specified.
308.sp
309When no feature options are given, the \fBdefault\fP feature is activated for
310every selected package.
311.sp
312\fB\-\-features\fP \fIFEATURES\fP
313.RS 4
314Space or comma separated list of features to activate. These features only
315apply to the current directory\(cqs package. Features of direct dependencies
316may be enabled with \fB<dep\-name>/<feature\-name>\fP syntax. This flag may be
317specified multiple times, which enables all specified features.
318.RE
319.sp
320\fB\-\-all\-features\fP
321.RS 4
322Activate all available features of all selected packages.
323.RE
324.sp
325\fB\-\-no\-default\-features\fP
326.RS 4
327Do not activate the \fBdefault\fP feature of the current directory\(cqs
328package.
329.RE
330.SS "Compilation Options"
331.sp
332\fB\-\-target\fP \fITRIPLE\fP
333.RS 4
334Install for the given architecture. The default is the host
335architecture. The general format of the triple is
336\fB<arch><sub>\-<vendor>\-<sys>\-<abi>\fP. Run \fBrustc \-\-print target\-list\fP for a
337list of supported targets.
338.sp
339This may also be specified with the \fBbuild.target\fP
340.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
341.sp
342Note that specifying this flag makes Cargo run in a different mode where the
343target artifacts are placed in a separate directory. See the
344.URL "https://doc.rust\-lang.org/cargo/guide/build\-cache.html" "build cache" " "
345documentation for more details.
346.RE
347.sp
348\fB\-\-target\-dir\fP \fIDIRECTORY\fP
349.RS 4
350Directory for all generated artifacts and intermediate files. May also be
351specified with the \fBCARGO_TARGET_DIR\fP environment variable, or the
352\fBbuild.target\-dir\fP \c
353.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
354Defaults
355to \fBtarget\fP in the root of the workspace.
356.RE
357.sp
358\fB\-\-debug\fP
359.RS 4
360Build with the \fBdev\fP profile instead the \fBrelease\fP profile.
361.RE
362.SS "Manifest Options"
363.sp
364\fB\-\-frozen\fP, \fB\-\-locked\fP
365.RS 4
366Either of these flags requires that the \fBCargo.lock\fP file is
367up\-to\-date. If the lock file is missing, or it needs to be updated, Cargo will
368exit with an error. The \fB\-\-frozen\fP flag also prevents Cargo from
369attempting to access the network to determine if it is out\-of\-date.
370.sp
371These may be used in environments where you want to assert that the
372\fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network
373access.
374.RE
375.sp
376\fB\-\-offline\fP
377.RS 4
378Prevents Cargo from accessing the network for any reason. Without this
379flag, Cargo will stop with an error if it needs to access the network and
380the network is not available. With this flag, Cargo will attempt to
381proceed without the network if possible.
382.sp
383Beware that this may result in different dependency resolution than online
384mode. Cargo will restrict itself to crates that are downloaded locally, even
385if there might be a newer version as indicated in the local copy of the index.
386See the \fBcargo\-fetch\fP(1) command to download dependencies before going
387offline.
388.sp
389May also be specified with the \fBnet.offline\fP \c
390.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
391.RE
392.SS "Miscellaneous Options"
393.sp
394\fB\-j\fP \fIN\fP, \fB\-\-jobs\fP \fIN\fP
395.RS 4
396Number of parallel jobs to run. May also be specified with the
397\fBbuild.jobs\fP \c
398.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
399Defaults to
400the number of CPUs.
401.RE
402.SS "Display Options"
403.sp
404\fB\-v\fP, \fB\-\-verbose\fP
405.RS 4
406Use verbose output. May be specified twice for "very verbose" output which
407includes extra output such as dependency warnings and build script output.
408May also be specified with the \fBterm.verbose\fP
409.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
410.RE
411.sp
412\fB\-q\fP, \fB\-\-quiet\fP
413.RS 4
414No output printed to stdout.
415.RE
416.sp
417\fB\-\-color\fP \fIWHEN\fP
418.RS 4
419Control when colored output is used. Valid values:
420.sp
421.RS 4
422.ie n \{\
423\h'-04'\(bu\h'+03'\c
424.\}
425.el \{\
426. sp -1
427. IP \(bu 2.3
428.\}
429\fBauto\fP (default): Automatically detect if color support is available on the
430terminal.
431.RE
432.sp
433.RS 4
434.ie n \{\
435\h'-04'\(bu\h'+03'\c
436.\}
437.el \{\
438. sp -1
439. IP \(bu 2.3
440.\}
441\fBalways\fP: Always display colors.
442.RE
443.sp
444.RS 4
445.ie n \{\
446\h'-04'\(bu\h'+03'\c
447.\}
448.el \{\
449. sp -1
450. IP \(bu 2.3
451.\}
452\fBnever\fP: Never display colors.
453.RE
454.sp
455May also be specified with the \fBterm.color\fP
456.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
457.RE
458.SS "Common Options"
459.sp
460\fB+TOOLCHAIN\fP
461.RS 4
462If Cargo has been installed with rustup, and the first argument to \fBcargo\fP
463begins with \fB+\fP, it will be interpreted as a rustup toolchain name (such
464as \fB+stable\fP or \fB+nightly\fP).
465See the \c
466.URL "https://github.com/rust\-lang/rustup/" "rustup documentation"
467for more information about how toolchain overrides work.
468.RE
469.sp
470\fB\-h\fP, \fB\-\-help\fP
471.RS 4
472Prints help information.
473.RE
474.sp
475\fB\-Z\fP \fIFLAG\fP...
476.RS 4
477Unstable (nightly\-only) flags to Cargo. Run \fBcargo \-Z help\fP for
478details.
479.RE
480.SH "ENVIRONMENT"
481.sp
482See \c
483.URL "https://doc.rust\-lang.org/cargo/reference/environment\-variables.html" "the reference" " "
484for
485details on environment variables that Cargo reads.
486.SH "EXIT STATUS"
487.sp
4880
489.RS 4
490Cargo succeeded.
491.RE
492.sp
493101
494.RS 4
495Cargo failed to complete.
496.RE
497.SH "EXAMPLES"
498.sp
499.RS 4
500.ie n \{\
501\h'-04' 1.\h'+01'\c
502.\}
503.el \{\
504. sp -1
505. IP " 1." 4.2
506.\}
507Install or upgrade a package from crates.io:
508.sp
509.if n .RS 4
510.nf
511cargo install ripgrep
512.fi
513.if n .RE
514.RE
515.sp
516.RS 4
517.ie n \{\
518\h'-04' 2.\h'+01'\c
519.\}
520.el \{\
521. sp -1
522. IP " 2." 4.2
523.\}
524Install or reinstall the package in the current directory:
525.sp
526.if n .RS 4
527.nf
528cargo install \-\-path .
529.fi
530.if n .RE
531.RE
532.sp
533.RS 4
534.ie n \{\
535\h'-04' 3.\h'+01'\c
536.\}
537.el \{\
538. sp -1
539. IP " 3." 4.2
540.\}
541View the list of installed packages:
542.sp
543.if n .RS 4
544.nf
545cargo install \-\-list
546.fi
547.if n .RE
548.RE
549.SH "SEE ALSO"
550.sp
551\fBcargo\fP(1), \fBcargo\-uninstall\fP(1), \fBcargo\-search\fP(1), \fBcargo\-publish\fP(1)