Jeff Vander Stoep | 956d143 | 2020-09-18 13:46:24 +0200 | [diff] [blame] | 1 | '\" 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" |
| 31 | cargo\-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 |
| 43 | This command manages Cargo\(cqs local set of installed binary crates. Only |
| 44 | packages which have executable \fB[[bin]]\fP or \fB[[example]]\fP targets can be |
| 45 | installed, and all executables are installed into the installation root\(cqs |
| 46 | \fBbin\fP folder. |
| 47 | .sp |
| 48 | The 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 |
| 106 | There are multiple sources from which a crate can be installed. The default |
| 107 | location is crates.io but the \fB\-\-git\fP, \fB\-\-path\fP, and \fB\-\-registry\fP flags can |
| 108 | change this source. If the source contains more than one package (such as |
| 109 | crates.io or a git repository with multiple crates) the \fICRATE\fP argument is |
| 110 | required to indicate which crate should be installed. |
| 111 | .sp |
| 112 | Crates from crates.io can optionally specify the version they wish to install |
| 113 | via the \fB\-\-version\fP flags, and similarly packages from git repositories can |
| 114 | optionally specify the branch, tag, or revision that should be installed. If a |
| 115 | crate has multiple binaries, the \fB\-\-bin\fP argument can selectively install only |
| 116 | one of them, and if you\(cqd rather install examples the \fB\-\-example\fP argument can |
| 117 | be used as well. |
| 118 | .sp |
| 119 | If the package is already installed, Cargo will reinstall it if the installed |
| 120 | version does not appear to be up\-to\-date. If any of the following values |
| 121 | change, 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 | .\} |
| 131 | The 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 | .\} |
| 142 | The 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 | .\} |
| 153 | The 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 | .\} |
| 164 | The 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 | .\} |
| 175 | The target (\fB\-\-target\fP). |
| 176 | .RE |
| 177 | .sp |
| 178 | Installing with \fB\-\-path\fP will always build and install, unless there are |
| 179 | conflicting binaries from another package. The \fB\-\-force\fP flag may be used to |
| 180 | force Cargo to always reinstall the package. |
| 181 | .sp |
| 182 | If the source is crates.io or \fB\-\-git\fP then by default the crate will be built |
| 183 | in a temporary target directory. To avoid this, the target directory can be |
| 184 | specified by setting the \fBCARGO_TARGET_DIR\fP environment variable to a relative |
| 185 | path. In particular, this can be useful for caching build artifacts on |
| 186 | continuous integration systems. |
| 187 | .sp |
| 188 | By default, the \fBCargo.lock\fP file that is included with the package will be |
| 189 | ignored. This means that Cargo will recompute which versions of dependencies |
| 190 | to use, possibly using newer versions that have been released since the |
| 191 | package was published. The \fB\-\-locked\fP flag can be used to force Cargo to use |
| 192 | the packaged \fBCargo.lock\fP file if it is available. This may be useful for |
| 193 | ensuring reproducible builds, to use the exact same set of dependencies that |
| 194 | were available when the package was published. It may also be useful if a |
| 195 | newer version of a dependency is published that no longer builds on your |
| 196 | system, or has other problems. The downside to using \fB\-\-locked\fP is that you |
| 197 | will not receive any fixes or updates to any dependency. Note that Cargo did |
| 198 | not start publishing \fBCargo.lock\fP files until version 1.37, which means |
| 199 | packages published with prior versions will not have a \fBCargo.lock\fP file |
| 200 | available. |
| 201 | .SH "OPTIONS" |
| 202 | .SS "Install Options" |
| 203 | .sp |
| 204 | \fB\-\-vers\fP \fIVERSION\fP, \fB\-\-version\fP \fIVERSION\fP |
| 205 | .RS 4 |
| 206 | Specify a version to install. This may be a |
| 207 | .URL "https://doc.rust\-lang.org/cargo/reference/specifying\-dependencies.md" "version requirement" "," |
| 208 | like |
| 209 | \fB~1.2\fP, to have Cargo select the newest version from the given |
| 210 | requirement. 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 |
| 212 | install exactly that version; it is \fBnot\fP treated as a caret requirement |
| 213 | like Cargo dependencies are. |
| 214 | .RE |
| 215 | .sp |
| 216 | \fB\-\-git\fP \fIURL\fP |
| 217 | .RS 4 |
| 218 | Git URL to install the specified crate from. |
| 219 | .RE |
| 220 | .sp |
| 221 | \fB\-\-branch\fP \fIBRANCH\fP |
| 222 | .RS 4 |
| 223 | Branch to use when installing from git. |
| 224 | .RE |
| 225 | .sp |
| 226 | \fB\-\-tag\fP \fITAG\fP |
| 227 | .RS 4 |
| 228 | Tag to use when installing from git. |
| 229 | .RE |
| 230 | .sp |
| 231 | \fB\-\-rev\fP \fISHA\fP |
| 232 | .RS 4 |
| 233 | Specific commit to use when installing from git. |
| 234 | .RE |
| 235 | .sp |
| 236 | \fB\-\-path\fP \fIPATH\fP |
| 237 | .RS 4 |
| 238 | Filesystem path to local crate to install. |
| 239 | .RE |
| 240 | .sp |
| 241 | \fB\-\-list\fP |
| 242 | .RS 4 |
| 243 | List all installed packages and their versions. |
| 244 | .RE |
| 245 | .sp |
| 246 | \fB\-f\fP, \fB\-\-force\fP |
| 247 | .RS 4 |
| 248 | Force overwriting existing crates or binaries. This can be used if a |
| 249 | package has installed a binary with the same name as another package. This |
| 250 | is also useful if something has changed on the system that you want to |
| 251 | rebuild with, such as a newer version of \fBrustc\fP. |
| 252 | .RE |
| 253 | .sp |
| 254 | \fB\-\-no\-track\fP |
| 255 | .RS 4 |
| 256 | By default, Cargo keeps track of the installed packages with a metadata |
| 257 | file stored in the installation root directory. This flag tells Cargo not |
| 258 | to use or create that file. With this flag, Cargo will refuse to overwrite |
| 259 | any existing files unless the \fB\-\-force\fP flag is used. This also disables |
| 260 | Cargo\(cqs ability to protect against multiple concurrent invocations of |
| 261 | Cargo installing at the same time. |
| 262 | .RE |
| 263 | .sp |
| 264 | \fB\-\-bin\fP \fINAME\fP... |
| 265 | .RS 4 |
| 266 | Install only the specified binary. |
| 267 | .RE |
| 268 | .sp |
| 269 | \fB\-\-bins\fP |
| 270 | .RS 4 |
| 271 | Install all binaries. |
| 272 | .RE |
| 273 | .sp |
| 274 | \fB\-\-example\fP \fINAME\fP... |
| 275 | .RS 4 |
| 276 | Install only the specified example. |
| 277 | .RE |
| 278 | .sp |
| 279 | \fB\-\-examples\fP |
| 280 | .RS 4 |
| 281 | Install all examples. |
| 282 | .RE |
| 283 | .sp |
| 284 | \fB\-\-root\fP \fIDIR\fP |
| 285 | .RS 4 |
| 286 | Directory to install packages into. |
| 287 | .RE |
| 288 | .sp |
| 289 | \fB\-\-registry\fP \fIREGISTRY\fP |
| 290 | .RS 4 |
| 291 | Name 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" "." |
| 293 | If 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 |
| 299 | The URL of the registry index to use. |
| 300 | .RE |
| 301 | .SS "Feature Selection" |
| 302 | .sp |
| 303 | The feature flags allow you to control the enabled features for the "current" |
| 304 | package. The "current" package is the package in the current directory, or the |
| 305 | one specified in \fB\-\-manifest\-path\fP. If running in the root of a virtual |
| 306 | workspace, then the default features are selected for all workspace members, |
| 307 | or all features if \fB\-\-all\-features\fP is specified. |
| 308 | .sp |
| 309 | When no feature options are given, the \fBdefault\fP feature is activated for |
| 310 | every selected package. |
| 311 | .sp |
| 312 | \fB\-\-features\fP \fIFEATURES\fP |
| 313 | .RS 4 |
| 314 | Space or comma separated list of features to activate. These features only |
| 315 | apply to the current directory\(cqs package. Features of direct dependencies |
| 316 | may be enabled with \fB<dep\-name>/<feature\-name>\fP syntax. This flag may be |
| 317 | specified multiple times, which enables all specified features. |
| 318 | .RE |
| 319 | .sp |
| 320 | \fB\-\-all\-features\fP |
| 321 | .RS 4 |
| 322 | Activate all available features of all selected packages. |
| 323 | .RE |
| 324 | .sp |
| 325 | \fB\-\-no\-default\-features\fP |
| 326 | .RS 4 |
| 327 | Do not activate the \fBdefault\fP feature of the current directory\(cqs |
| 328 | package. |
| 329 | .RE |
| 330 | .SS "Compilation Options" |
| 331 | .sp |
| 332 | \fB\-\-target\fP \fITRIPLE\fP |
| 333 | .RS 4 |
| 334 | Install for the given architecture. The default is the host |
| 335 | architecture. The general format of the triple is |
| 336 | \fB<arch><sub>\-<vendor>\-<sys>\-<abi>\fP. Run \fBrustc \-\-print target\-list\fP for a |
| 337 | list of supported targets. |
| 338 | .sp |
| 339 | This may also be specified with the \fBbuild.target\fP |
| 340 | .URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "." |
| 341 | .sp |
| 342 | Note that specifying this flag makes Cargo run in a different mode where the |
| 343 | target artifacts are placed in a separate directory. See the |
| 344 | .URL "https://doc.rust\-lang.org/cargo/guide/build\-cache.html" "build cache" " " |
| 345 | documentation for more details. |
| 346 | .RE |
| 347 | .sp |
| 348 | \fB\-\-target\-dir\fP \fIDIRECTORY\fP |
| 349 | .RS 4 |
| 350 | Directory for all generated artifacts and intermediate files. May also be |
| 351 | specified 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" "." |
| 354 | Defaults |
| 355 | to \fBtarget\fP in the root of the workspace. |
| 356 | .RE |
| 357 | .sp |
| 358 | \fB\-\-debug\fP |
| 359 | .RS 4 |
| 360 | Build 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 |
| 366 | Either of these flags requires that the \fBCargo.lock\fP file is |
| 367 | up\-to\-date. If the lock file is missing, or it needs to be updated, Cargo will |
| 368 | exit with an error. The \fB\-\-frozen\fP flag also prevents Cargo from |
| 369 | attempting to access the network to determine if it is out\-of\-date. |
| 370 | .sp |
| 371 | These 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 |
| 373 | access. |
| 374 | .RE |
| 375 | .sp |
| 376 | \fB\-\-offline\fP |
| 377 | .RS 4 |
| 378 | Prevents Cargo from accessing the network for any reason. Without this |
| 379 | flag, Cargo will stop with an error if it needs to access the network and |
| 380 | the network is not available. With this flag, Cargo will attempt to |
| 381 | proceed without the network if possible. |
| 382 | .sp |
| 383 | Beware that this may result in different dependency resolution than online |
| 384 | mode. Cargo will restrict itself to crates that are downloaded locally, even |
| 385 | if there might be a newer version as indicated in the local copy of the index. |
| 386 | See the \fBcargo\-fetch\fP(1) command to download dependencies before going |
| 387 | offline. |
| 388 | .sp |
| 389 | May 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 |
| 396 | Number 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" "." |
| 399 | Defaults to |
| 400 | the number of CPUs. |
| 401 | .RE |
| 402 | .SS "Display Options" |
| 403 | .sp |
| 404 | \fB\-v\fP, \fB\-\-verbose\fP |
| 405 | .RS 4 |
| 406 | Use verbose output. May be specified twice for "very verbose" output which |
| 407 | includes extra output such as dependency warnings and build script output. |
| 408 | May 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 |
| 414 | No output printed to stdout. |
| 415 | .RE |
| 416 | .sp |
| 417 | \fB\-\-color\fP \fIWHEN\fP |
| 418 | .RS 4 |
| 419 | Control 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 |
| 430 | terminal. |
| 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 |
| 455 | May 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 |
| 462 | If Cargo has been installed with rustup, and the first argument to \fBcargo\fP |
| 463 | begins with \fB+\fP, it will be interpreted as a rustup toolchain name (such |
| 464 | as \fB+stable\fP or \fB+nightly\fP). |
| 465 | See the \c |
| 466 | .URL "https://github.com/rust\-lang/rustup/" "rustup documentation" |
| 467 | for more information about how toolchain overrides work. |
| 468 | .RE |
| 469 | .sp |
| 470 | \fB\-h\fP, \fB\-\-help\fP |
| 471 | .RS 4 |
| 472 | Prints help information. |
| 473 | .RE |
| 474 | .sp |
| 475 | \fB\-Z\fP \fIFLAG\fP... |
| 476 | .RS 4 |
| 477 | Unstable (nightly\-only) flags to Cargo. Run \fBcargo \-Z help\fP for |
| 478 | details. |
| 479 | .RE |
| 480 | .SH "ENVIRONMENT" |
| 481 | .sp |
| 482 | See \c |
| 483 | .URL "https://doc.rust\-lang.org/cargo/reference/environment\-variables.html" "the reference" " " |
| 484 | for |
| 485 | details on environment variables that Cargo reads. |
| 486 | .SH "EXIT STATUS" |
| 487 | .sp |
| 488 | 0 |
| 489 | .RS 4 |
| 490 | Cargo succeeded. |
| 491 | .RE |
| 492 | .sp |
| 493 | 101 |
| 494 | .RS 4 |
| 495 | Cargo 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 | .\} |
| 507 | Install or upgrade a package from crates.io: |
| 508 | .sp |
| 509 | .if n .RS 4 |
| 510 | .nf |
| 511 | cargo 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 | .\} |
| 524 | Install or reinstall the package in the current directory: |
| 525 | .sp |
| 526 | .if n .RS 4 |
| 527 | .nf |
| 528 | cargo 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 | .\} |
| 541 | View the list of installed packages: |
| 542 | .sp |
| 543 | .if n .RS 4 |
| 544 | .nf |
| 545 | cargo 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) |