1CARGO-INSTALL(1) CARGO-INSTALL(1)
2
3
4
6 cargo-install - Build and install a Rust binary
7
9 cargo install [OPTIONS] CRATE...
10 cargo install [OPTIONS] --path PATH
11 cargo install [OPTIONS] --git URL [CRATE...]
12 cargo install [OPTIONS] --list
13
15 This command manages Cargo’s local set of installed binary crates. Only
16 packages which have [[bin]] targets can be installed, and all binaries
17 are installed into the installation root’s bin folder.
18
19 The installation root is determined, in order of precedence:
20
21 · --root option
22
23 · CARGO_INSTALL_ROOT environment variable
24
25 · install.root Cargo config value
26 <https://doc.rust-lang.org/cargo/reference/config.html>
27
28 · CARGO_HOME environment variable
29
30 · $HOME/.cargo
31
32 There are multiple sources from which a crate can be installed. The
33 default location is crates.io but the --git, --path, and registry flags
34 can change this source. If the source contains more than one package
35 (such as crates.io or a git repository with multiple crates) the CRATE
36 argument is required to indicate which crate should be installed.
37
38 Crates from crates.io can optionally specify the version they wish to
39 install via the --version flags, and similarly packages from git
40 repositories can optionally specify the branch, tag, or revision that
41 should be installed. If a crate has multiple binaries, the --bin
42 argument can selectively install only one of them, and if you’d rather
43 install examples the --example argument can be used as well.
44
45 If the source is crates.io or --git then by default the crate will be
46 built in a temporary target directory. To avoid this, the target
47 directory can be specified by setting the CARGO_TARGET_DIR environment
48 variable to a relative path. In particular, this can be useful for
49 caching build artifacts on continuous integration systems.
50
52 Install Options
53 --vers VERSION, --version VERSION
54 Specify a version to install.
55
56 --git URL
57 Git URL to install the specified crate from.
58
59 --branch BRANCH
60 Branch to use when installing from git.
61
62 --tag TAG
63 Tag to use when installing from git.
64
65 --rev SHA
66 Specific commit to use when installing from git.
67
68 --path PATH
69 Filesystem path to local crate to install.
70
71 --list
72 List all installed packages and their versions.
73
74 -f, --force
75 Force overwriting existing crates or binaries. This can be used to
76 reinstall or upgrade a crate.
77
78 --bin NAME...
79 Install only the specified binary.
80
81 --bins
82 Install all binaries.
83
84 --example NAME...
85 Install only the specified example.
86
87 --examples
88 Install all examples.
89
90 --root DIR
91 Directory to install packages into.
92
93 --registry REGISTRY
94 Name of the registry to use. Registry names are defined in Cargo
95 config files
96 <https://doc.rust-lang.org/cargo/reference/config.html>. If not
97 specified, the default registry is used, which is defined by the
98 registry.default config key which defaults to crates-io.
99
100 Feature Selection
101 When no feature options are given, the default feature is activated for
102 every selected package.
103
104 --features FEATURES
105 Space or comma separated list of features to activate. These
106 features only apply to the current directory’s package. Features of
107 direct dependencies may be enabled with <dep-name>/<feature-name>
108 syntax.
109
110 --all-features
111 Activate all available features of all selected packages.
112
113 --no-default-features
114 Do not activate the default feature of the current directory’s
115 package.
116
117 Compilation Options
118 --target TRIPLE
119 Install for the given architecture. The default is the host
120 architecture. The general format of the triple is
121 <arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for
122 a list of supported targets.
123
124 This may also be specified with the build.target config value
125 <https://doc.rust-lang.org/cargo/reference/config.html>.
126
127 --debug
128 Build with the dev profile instead the release profile.
129
130 Miscellaneous Options
131 -j N, --jobs N
132 Number of parallel jobs to run. May also be specified with the
133 build.jobs config value
134 <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
135 to the number of CPUs.
136
137 Display Options
138 -v, --verbose
139 Use verbose output. May be specified twice for "very verbose"
140 output which includes extra output such as dependency warnings and
141 build script output. May also be specified with the term.verbose
142 config value
143 <https://doc.rust-lang.org/cargo/reference/config.html>.
144
145 -q, --quiet
146 No output printed to stdout.
147
148 --color WHEN
149 Control when colored output is used. Valid values:
150
151 · auto (default): Automatically detect if color support is
152 available on the terminal.
153
154 · always: Always display colors.
155
156 · never: Never display colors.
157
158 May also be specified with the term.color config value
159 <https://doc.rust-lang.org/cargo/reference/config.html>.
160
161 Common Options
162 -h, --help
163 Prints help information.
164
165 -Z FLAG...
166 Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
167 details.
168
170 See the reference
171 <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
172 for details on environment variables that Cargo reads.
173
175 0
176 Cargo succeeded.
177
178 101
179 Cargo failed to complete.
180
182 1. Install a package from crates.io:
183
184 cargo install ripgrep
185
186 2. Reinstall or upgrade a package:
187
188 cargo install ripgrep --force
189
191 cargo(1), cargo-uninstall(1), cargo-search(1), cargo-publish(1)
192
193
194
195 2019-03-31 CARGO-INSTALL(1)