Skip to content

Instantly share code, notes, and snippets.

@weihanglo
Created February 9, 2025 16:12
Show Gist options
  • Save weihanglo/87a9b7241ed8e6dacebd8e89e5ca47a8 to your computer and use it in GitHub Desktop.
Save weihanglo/87a9b7241ed8e6dacebd8e89e5ca47a8 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
<svg width="1037px" height="6392px" xmlns="http://www.w3.org/2000/svg">
<style>
.fg { fill: #AAAAAA }
.bg { background: #000000 }
.container {
padding: 0 10px;
line-height: 18px;
}
.bold { font-weight: bold; }
.underline { text-decoration-line: underline; }
tspan {
font: 14px SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
white-space: pre;
line-height: 18px;
}
</style>
<rect width="100%" height="100%" y="0" rx="4.5" class="bg" />
<text xml:space="preserve" class="container fg">
<tspan x="10px" y="28px"><tspan class="underline">CARGO-BUILD(1) General Commands Manual CARGO-BUILD(1)</tspan>
</tspan>
<tspan x="10px" y="46px">
</tspan>
<tspan x="10px" y="64px"><tspan class="underline bold">NAME</tspan>
</tspan>
<tspan x="10px" y="82px"><tspan> cargo-build — Compile the current package</tspan>
</tspan>
<tspan x="10px" y="100px">
</tspan>
<tspan x="10px" y="118px"><tspan class="bold">SYNOPSIS</tspan>
</tspan>
<tspan x="10px" y="136px"><tspan> </tspan><tspan class="bold">cargo build [</tspan><tspan class="underline bold">options]</tspan>
</tspan>
<tspan x="10px" y="154px">
</tspan>
<tspan x="10px" y="172px"><tspan class="underline bold">DESCRIPTION</tspan>
</tspan>
<tspan x="10px" y="190px"><tspan> Compile local packages and all of their dependencies.</tspan>
</tspan>
<tspan x="10px" y="208px">
</tspan>
<tspan x="10px" y="226px"><tspan class="bold">OPTIONS</tspan>
</tspan>
<tspan x="10px" y="244px"><tspan> </tspan><tspan class="bold">Package Selection</tspan>
</tspan>
<tspan x="10px" y="262px"><tspan> By default, when no package selection options are given, the packages selected depend on the</tspan>
</tspan>
<tspan x="10px" y="280px"><tspan> selected manifest file (based on the current working directory if </tspan><tspan class="bold">--manifest-path is not</tspan>
</tspan>
<tspan x="10px" y="298px"><tspan class="bold"> given). If the manifest is the root of a workspace then the workspaces default members are</tspan>
</tspan>
<tspan x="10px" y="316px"><tspan class="bold"> selected, otherwise only the package defined by the manifest will be selected.</tspan>
</tspan>
<tspan x="10px" y="334px">
</tspan>
<tspan x="10px" y="352px"><tspan class="bold"> The default members of a workspace can be set explicitly with the workspace.default-members</tspan>
</tspan>
<tspan x="10px" y="370px"><tspan> key in the root manifest. If this is not set, a virtual workspace will include all workspace</tspan>
</tspan>
<tspan x="10px" y="388px"><tspan> members (equivalent to passing </tspan><tspan class="bold">--workspace), and a non-virtual workspace will include only the</tspan>
</tspan>
<tspan x="10px" y="406px"><tspan class="bold"> root crate itself.</tspan>
</tspan>
<tspan x="10px" y="424px">
</tspan>
<tspan x="10px" y="442px"><tspan class="bold"> -p </tspan><tspan class="underline bold">spec…, --package spec…</tspan>
</tspan>
<tspan x="10px" y="460px"><tspan class="underline bold"> Build only the specified packages. See cargo-pkgid(1) for the SPEC format. This flag may</tspan>
</tspan>
<tspan x="10px" y="478px"><tspan class="underline bold"> be specified multiple times and supports common Unix glob patterns like *, ? and [].</tspan>
</tspan>
<tspan x="10px" y="496px"><tspan class="underline bold"> However, to avoid your shell accidentally expanding glob patterns before Cargo handles</tspan>
</tspan>
<tspan x="10px" y="514px"><tspan class="underline bold"> them, you must use single quotes or double quotes around each pattern.</tspan>
</tspan>
<tspan x="10px" y="532px">
</tspan>
<tspan x="10px" y="550px"><tspan class="underline bold"> --workspace</tspan>
</tspan>
<tspan x="10px" y="568px"><tspan> Build all members in the workspace.</tspan>
</tspan>
<tspan x="10px" y="586px">
</tspan>
<tspan x="10px" y="604px"><tspan> </tspan><tspan class="bold">--all</tspan>
</tspan>
<tspan x="10px" y="622px"><tspan> Deprecated alias for </tspan><tspan class="bold">--workspace.</tspan>
</tspan>
<tspan x="10px" y="640px">
</tspan>
<tspan x="10px" y="658px"><tspan class="bold"> --exclude </tspan><tspan class="underline bold">SPEC…</tspan>
</tspan>
<tspan x="10px" y="676px"><tspan class="underline bold"> Exclude the specified packages. Must be used in conjunction with the --workspace flag.</tspan>
</tspan>
<tspan x="10px" y="694px"><tspan class="underline bold"> This flag may be specified multiple times and supports common Unix glob patterns like *, ?</tspan>
</tspan>
<tspan x="10px" y="712px"><tspan> and </tspan><tspan class="bold">[]. However, to avoid your shell accidentally expanding glob patterns before Cargo</tspan>
</tspan>
<tspan x="10px" y="730px"><tspan class="bold"> handles them, you must use single quotes or double quotes around each pattern.</tspan>
</tspan>
<tspan x="10px" y="748px">
</tspan>
<tspan x="10px" y="766px"><tspan class="bold"> Target Selection</tspan>
</tspan>
<tspan x="10px" y="784px"><tspan> When no target selection options are given, </tspan><tspan class="bold">cargo build will build all binary and library</tspan>
</tspan>
<tspan x="10px" y="802px"><tspan class="bold"> targets of the selected packages. Binaries are skipped if they have required-features that are</tspan>
</tspan>
<tspan x="10px" y="820px"><tspan class="bold"> missing.</tspan>
</tspan>
<tspan x="10px" y="838px">
</tspan>
<tspan x="10px" y="856px"><tspan class="bold"> Binary targets are automatically built if there is an integration test or benchmark being</tspan>
</tspan>
<tspan x="10px" y="874px"><tspan class="bold"> selected to build. This allows an integration test to execute the binary to exercise and test</tspan>
</tspan>
<tspan x="10px" y="892px"><tspan class="bold"> its behavior. The CARGO_BIN_EXE_&lt;name&gt; </tspan><tspan class="underline bold">environment variable</tspan>
</tspan>
<tspan x="10px" y="910px"><tspan> &lt;https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-crates&gt;</tspan>
</tspan>
<tspan x="10px" y="928px"><tspan> is set when the integration test is built so that it can use the </tspan><tspan class="underline bold">env macro</tspan>
</tspan>
<tspan x="10px" y="946px"><tspan> &lt;https://doc.rust-lang.org/std/macro.env.html&gt; to locate the executable.</tspan>
</tspan>
<tspan x="10px" y="964px">
</tspan>
<tspan x="10px" y="982px"><tspan> Passing target selection flags will build only the specified targets.</tspan>
</tspan>
<tspan x="10px" y="1000px">
</tspan>
<tspan x="10px" y="1018px"><tspan> Note that </tspan><tspan class="bold">--bin, --example, --test and --bench flags also support common Unix glob patterns</tspan>
</tspan>
<tspan x="10px" y="1036px"><tspan class="bold"> like *, ? and []. However, to avoid your shell accidentally expanding glob patterns before</tspan>
</tspan>
<tspan x="10px" y="1054px"><tspan class="bold"> Cargo handles them, you must use single quotes or double quotes around each glob pattern.</tspan>
</tspan>
<tspan x="10px" y="1072px">
</tspan>
<tspan x="10px" y="1090px"><tspan class="bold"> --lib</tspan>
</tspan>
<tspan x="10px" y="1108px"><tspan> Build the package’s library.</tspan>
</tspan>
<tspan x="10px" y="1126px">
</tspan>
<tspan x="10px" y="1144px"><tspan> </tspan><tspan class="bold">--bin </tspan><tspan class="underline bold">name…</tspan>
</tspan>
<tspan x="10px" y="1162px"><tspan class="underline bold"> Build the specified binary. This flag may be specified multiple times and supports common</tspan>
</tspan>
<tspan x="10px" y="1180px"><tspan class="underline bold"> Unix glob patterns.</tspan>
</tspan>
<tspan x="10px" y="1198px">
</tspan>
<tspan x="10px" y="1216px"><tspan class="underline bold"> --bins</tspan>
</tspan>
<tspan x="10px" y="1234px"><tspan> Build all binary targets.</tspan>
</tspan>
<tspan x="10px" y="1252px">
</tspan>
<tspan x="10px" y="1270px"><tspan> </tspan><tspan class="bold">--example </tspan><tspan class="underline bold">name…</tspan>
</tspan>
<tspan x="10px" y="1288px"><tspan class="underline bold"> Build the specified example. This flag may be specified multiple times and supports common</tspan>
</tspan>
<tspan x="10px" y="1306px"><tspan class="underline bold"> Unix glob patterns.</tspan>
</tspan>
<tspan x="10px" y="1324px">
</tspan>
<tspan x="10px" y="1342px"><tspan class="underline bold"> --examples</tspan>
</tspan>
<tspan x="10px" y="1360px"><tspan> Build all example targets.</tspan>
</tspan>
<tspan x="10px" y="1378px">
</tspan>
<tspan x="10px" y="1396px"><tspan> </tspan><tspan class="bold">--test </tspan><tspan class="underline bold">name…</tspan>
</tspan>
<tspan x="10px" y="1414px"><tspan class="underline bold"> Build the specified integration test. This flag may be specified multiple times and</tspan>
</tspan>
<tspan x="10px" y="1432px"><tspan class="underline bold"> supports common Unix glob patterns.</tspan>
</tspan>
<tspan x="10px" y="1450px">
</tspan>
<tspan x="10px" y="1468px"><tspan class="underline bold"> --tests</tspan>
</tspan>
<tspan x="10px" y="1486px"><tspan> Build all targets that have the </tspan><tspan class="bold">test = true manifest flag set. By default this includes</tspan>
</tspan>
<tspan x="10px" y="1504px"><tspan class="bold"> the library and binaries built as unittests, and integration tests. Be aware that this</tspan>
</tspan>
<tspan x="10px" y="1522px"><tspan class="bold"> will also build any required dependencies, so the lib target may be built twice (once as a</tspan>
</tspan>
<tspan x="10px" y="1540px"><tspan class="bold"> unittest, and once as a dependency for binaries, integration tests, etc.). Targets may be</tspan>
</tspan>
<tspan x="10px" y="1558px"><tspan class="bold"> enabled or disabled by setting the test flag in the manifest settings for the target.</tspan>
</tspan>
<tspan x="10px" y="1576px">
</tspan>
<tspan x="10px" y="1594px"><tspan class="bold"> --bench </tspan><tspan class="underline bold">name…</tspan>
</tspan>
<tspan x="10px" y="1612px"><tspan class="underline bold"> Build the specified benchmark. This flag may be specified multiple times and supports</tspan>
</tspan>
<tspan x="10px" y="1630px"><tspan class="underline bold"> common Unix glob patterns.</tspan>
</tspan>
<tspan x="10px" y="1648px">
</tspan>
<tspan x="10px" y="1666px"><tspan class="underline bold"> --benches</tspan>
</tspan>
<tspan x="10px" y="1684px"><tspan> Build all targets that have the </tspan><tspan class="bold">bench = true manifest flag set. By default this includes</tspan>
</tspan>
<tspan x="10px" y="1702px"><tspan class="bold"> the library and binaries built as benchmarks, and bench targets. Be aware that this will</tspan>
</tspan>
<tspan x="10px" y="1720px"><tspan class="bold"> also build any required dependencies, so the lib target may be built twice (once as a</tspan>
</tspan>
<tspan x="10px" y="1738px"><tspan class="bold"> benchmark, and once as a dependency for binaries, benchmarks, etc.). Targets may be</tspan>
</tspan>
<tspan x="10px" y="1756px"><tspan class="bold"> enabled or disabled by setting the bench flag in the manifest settings for the target.</tspan>
</tspan>
<tspan x="10px" y="1774px">
</tspan>
<tspan x="10px" y="1792px"><tspan class="bold"> --all-targets</tspan>
</tspan>
<tspan x="10px" y="1810px"><tspan> Build all targets. This is equivalent to specifying </tspan><tspan class="bold">--lib --bins --tests --benches</tspan>
</tspan>
<tspan x="10px" y="1828px"><tspan> </tspan><tspan class="bold">--examples.</tspan>
</tspan>
<tspan x="10px" y="1846px">
</tspan>
<tspan x="10px" y="1864px"><tspan class="bold"> Feature Selection</tspan>
</tspan>
<tspan x="10px" y="1882px"><tspan> The feature flags allow you to control which features are enabled. When no feature options are</tspan>
</tspan>
<tspan x="10px" y="1900px"><tspan> given, the </tspan><tspan class="bold">default feature is activated for every selected package.</tspan>
</tspan>
<tspan x="10px" y="1918px">
</tspan>
<tspan x="10px" y="1936px"><tspan class="bold"> See </tspan><tspan class="underline bold">the features documentation</tspan>
</tspan>
<tspan x="10px" y="1954px"><tspan> &lt;https://doc.rust-lang.org/cargo/reference/features.html#command-line-feature-options&gt; for</tspan>
</tspan>
<tspan x="10px" y="1972px"><tspan> more details.</tspan>
</tspan>
<tspan x="10px" y="1990px">
</tspan>
<tspan x="10px" y="2008px"><tspan> </tspan><tspan class="bold">-F </tspan><tspan class="underline bold">features, --features features</tspan>
</tspan>
<tspan x="10px" y="2026px"><tspan> Space or comma separated list of features to activate. Features of workspace members may</tspan>
</tspan>
<tspan x="10px" y="2044px"><tspan> be enabled with </tspan><tspan class="bold">package-name/feature-name syntax. This flag may be specified multiple</tspan>
</tspan>
<tspan x="10px" y="2062px"><tspan class="bold"> times, which enables all specified features.</tspan>
</tspan>
<tspan x="10px" y="2080px">
</tspan>
<tspan x="10px" y="2098px"><tspan class="bold"> --all-features</tspan>
</tspan>
<tspan x="10px" y="2116px"><tspan> Activate all available features of all selected packages.</tspan>
</tspan>
<tspan x="10px" y="2134px">
</tspan>
<tspan x="10px" y="2152px"><tspan> </tspan><tspan class="bold">--no-default-features</tspan>
</tspan>
<tspan x="10px" y="2170px"><tspan> Do not activate the </tspan><tspan class="bold">default feature of the selected packages.</tspan>
</tspan>
<tspan x="10px" y="2188px">
</tspan>
<tspan x="10px" y="2206px"><tspan class="bold"> Compilation Options</tspan>
</tspan>
<tspan x="10px" y="2224px"><tspan> </tspan><tspan class="bold">--target </tspan><tspan class="underline bold">triple</tspan>
</tspan>
<tspan x="10px" y="2242px"><tspan> Build for the given architecture. The default is the host architecture. The general format</tspan>
</tspan>
<tspan x="10px" y="2260px"><tspan> of the triple is </tspan><tspan class="bold">&lt;arch&gt;&lt;sub&gt;-&lt;vendor&gt;-&lt;sys&gt;-&lt;abi&gt;. Run rustc --print target-list for a</tspan>
</tspan>
<tspan x="10px" y="2278px"><tspan class="bold"> list of supported targets. This flag may be specified multiple times.</tspan>
</tspan>
<tspan x="10px" y="2296px">
</tspan>
<tspan x="10px" y="2314px"><tspan class="bold"> This may also be specified with the build.target </tspan><tspan class="underline bold">config value</tspan>
</tspan>
<tspan x="10px" y="2332px"><tspan> &lt;https://doc.rust-lang.org/cargo/reference/config.html&gt;.</tspan>
</tspan>
<tspan x="10px" y="2350px">
</tspan>
<tspan x="10px" y="2368px"><tspan> Note that specifying this flag makes Cargo run in a different mode where the target</tspan>
</tspan>
<tspan x="10px" y="2386px"><tspan> artifacts are placed in a separate directory. See the </tspan><tspan class="underline">build cache</tspan>
</tspan>
<tspan x="10px" y="2404px"><tspan> &lt;https://doc.rust-lang.org/cargo/reference/build-cache.html&gt; documentation for more</tspan>
</tspan>
<tspan x="10px" y="2422px"><tspan> details.</tspan>
</tspan>
<tspan x="10px" y="2440px">
</tspan>
<tspan x="10px" y="2458px"><tspan> </tspan><tspan class="bold">-r, --release</tspan>
</tspan>
<tspan x="10px" y="2476px"><tspan> Build optimized artifacts with the </tspan><tspan class="bold">release profile. See also the --profile option for</tspan>
</tspan>
<tspan x="10px" y="2494px"><tspan class="bold"> choosing a specific profile by name.</tspan>
</tspan>
<tspan x="10px" y="2512px">
</tspan>
<tspan x="10px" y="2530px"><tspan class="bold"> --profile </tspan><tspan class="underline bold">name</tspan>
</tspan>
<tspan x="10px" y="2548px"><tspan> Build with the given profile. See </tspan><tspan class="underline">the reference</tspan>
</tspan>
<tspan x="10px" y="2566px"><tspan> &lt;https://doc.rust-lang.org/cargo/reference/profiles.html&gt; for more details on profiles.</tspan>
</tspan>
<tspan x="10px" y="2584px">
</tspan>
<tspan x="10px" y="2602px"><tspan> </tspan><tspan class="bold">--timings=</tspan><tspan class="underline bold">fmts</tspan>
</tspan>
<tspan x="10px" y="2620px"><tspan> Output information how long each compilation takes, and track concurrency information over</tspan>
</tspan>
<tspan x="10px" y="2638px"><tspan> time. Accepts an optional comma-separated list of output formats; </tspan><tspan class="bold">--timings without an</tspan>
</tspan>
<tspan x="10px" y="2656px"><tspan class="bold"> argument will default to --timings=html. Specifying an output format (rather than the</tspan>
</tspan>
<tspan x="10px" y="2674px"><tspan class="bold"> default) is unstable and requires -Zunstable-options. Valid output formats:</tspan>
</tspan>
<tspan x="10px" y="2692px">
</tspan>
<tspan x="10px" y="2710px"><tspan class="bold"> • html (unstable, requires -Zunstable-options): Write a human-readable file</tspan>
</tspan>
<tspan x="10px" y="2728px"><tspan class="bold"> cargo-timing.html to the target/cargo-timings directory with a report of the</tspan>
</tspan>
<tspan x="10px" y="2746px"><tspan class="bold"> compilation. Also write a report to the same directory with a timestamp in the</tspan>
</tspan>
<tspan x="10px" y="2764px"><tspan class="bold"> filename if you want to look at older runs. HTML output is suitable for human</tspan>
</tspan>
<tspan x="10px" y="2782px"><tspan class="bold"> consumption only, and does not provide machine-readable timing data.</tspan>
</tspan>
<tspan x="10px" y="2800px">
</tspan>
<tspan x="10px" y="2818px"><tspan class="bold"> • json (unstable, requires -Zunstable-options): Emit machine-readable JSON information</tspan>
</tspan>
<tspan x="10px" y="2836px"><tspan class="bold"> about timing information.</tspan>
</tspan>
<tspan x="10px" y="2854px">
</tspan>
<tspan x="10px" y="2872px"><tspan class="bold"> Output Options</tspan>
</tspan>
<tspan x="10px" y="2890px"><tspan> </tspan><tspan class="bold">--target-dir </tspan><tspan class="underline bold">directory</tspan>
</tspan>
<tspan x="10px" y="2908px"><tspan> Directory for all generated artifacts and intermediate files. May also be specified with</tspan>
</tspan>
<tspan x="10px" y="2926px"><tspan> the </tspan><tspan class="bold">CARGO_TARGET_DIR environment variable, or the build.target-dir </tspan><tspan class="underline bold">config value</tspan>
</tspan>
<tspan x="10px" y="2944px"><tspan> &lt;https://doc.rust-lang.org/cargo/reference/config.html&gt;. Defaults to </tspan><tspan class="bold">target in the root of</tspan>
</tspan>
<tspan x="10px" y="2962px"><tspan class="bold"> the workspace.</tspan>
</tspan>
<tspan x="10px" y="2980px">
</tspan>
<tspan x="10px" y="2998px"><tspan class="bold"> --artifact-dir </tspan><tspan class="underline bold">directory</tspan>
</tspan>
<tspan x="10px" y="3016px"><tspan> Copy final artifacts to this directory.</tspan>
</tspan>
<tspan x="10px" y="3034px">
</tspan>
<tspan x="10px" y="3052px"><tspan> This option is unstable and available only on the </tspan><tspan class="underline">nightly channel</tspan>
</tspan>
<tspan x="10px" y="3070px"><tspan> &lt;https://doc.rust-lang.org/book/appendix-07-nightly-rust.html&gt; and requires the </tspan><tspan class="bold">-Z</tspan>
</tspan>
<tspan x="10px" y="3088px"><tspan> </tspan><tspan class="bold">unstable-options flag to enable. See &lt;https://github.com/rust-lang/cargo/issues/6790&gt; for</tspan>
</tspan>
<tspan x="10px" y="3106px"><tspan class="bold"> more information.</tspan>
</tspan>
<tspan x="10px" y="3124px">
</tspan>
<tspan x="10px" y="3142px"><tspan class="bold"> Display Options</tspan>
</tspan>
<tspan x="10px" y="3160px"><tspan> </tspan><tspan class="bold">-v, --verbose</tspan>
</tspan>
<tspan x="10px" y="3178px"><tspan> Use verbose output. May be specified twice for “very verbose” output which includes extra</tspan>
</tspan>
<tspan x="10px" y="3196px"><tspan> output such as dependency warnings and build script output. May also be specified with the</tspan>
</tspan>
<tspan x="10px" y="3214px"><tspan> </tspan><tspan class="bold">term.verbose </tspan><tspan class="underline bold">config value &lt;https://doc.rust-lang.org/cargo/reference/config.html&gt;.</tspan>
</tspan>
<tspan x="10px" y="3232px">
</tspan>
<tspan x="10px" y="3250px"><tspan class="underline bold"> -q, --quiet</tspan>
</tspan>
<tspan x="10px" y="3268px"><tspan> Do not print cargo log messages. May also be specified with the </tspan><tspan class="bold">term.quiet </tspan><tspan class="underline bold">config value</tspan>
</tspan>
<tspan x="10px" y="3286px"><tspan> &lt;https://doc.rust-lang.org/cargo/reference/config.html&gt;.</tspan>
</tspan>
<tspan x="10px" y="3304px">
</tspan>
<tspan x="10px" y="3322px"><tspan> </tspan><tspan class="bold">--color </tspan><tspan class="underline bold">when</tspan>
</tspan>
<tspan x="10px" y="3340px"><tspan> Control when colored output is used. Valid values:</tspan>
</tspan>
<tspan x="10px" y="3358px">
</tspan>
<tspan x="10px" y="3376px"><tspan> • </tspan><tspan class="bold">auto (default): Automatically detect if color support is available on the terminal.</tspan>
</tspan>
<tspan x="10px" y="3394px">
</tspan>
<tspan x="10px" y="3412px"><tspan class="bold"> • always: Always display colors.</tspan>
</tspan>
<tspan x="10px" y="3430px">
</tspan>
<tspan x="10px" y="3448px"><tspan class="bold"> • never: Never display colors.</tspan>
</tspan>
<tspan x="10px" y="3466px">
</tspan>
<tspan x="10px" y="3484px"><tspan class="bold"> May also be specified with the term.color </tspan><tspan class="underline bold">config value</tspan>
</tspan>
<tspan x="10px" y="3502px"><tspan> &lt;https://doc.rust-lang.org/cargo/reference/config.html&gt;.</tspan>
</tspan>
<tspan x="10px" y="3520px">
</tspan>
<tspan x="10px" y="3538px"><tspan> </tspan><tspan class="bold">--message-format </tspan><tspan class="underline bold">fmt</tspan>
</tspan>
<tspan x="10px" y="3556px"><tspan> The output format for diagnostic messages. Can be specified multiple times and consists of</tspan>
</tspan>
<tspan x="10px" y="3574px"><tspan> comma-separated values. Valid values:</tspan>
</tspan>
<tspan x="10px" y="3592px">
</tspan>
<tspan x="10px" y="3610px"><tspan> • </tspan><tspan class="bold">human (default): Display in a human-readable text format. Conflicts with short and</tspan>
</tspan>
<tspan x="10px" y="3628px"><tspan class="bold"> json.</tspan>
</tspan>
<tspan x="10px" y="3646px">
</tspan>
<tspan x="10px" y="3664px"><tspan class="bold"> • short: Emit shorter, human-readable text messages. Conflicts with human and json.</tspan>
</tspan>
<tspan x="10px" y="3682px">
</tspan>
<tspan x="10px" y="3700px"><tspan class="bold"> • json: Emit JSON messages to stdout. See </tspan><tspan class="underline bold">the reference</tspan>
</tspan>
<tspan x="10px" y="3718px"><tspan> &lt;https://doc.rust-lang.org/cargo/reference/external-tools.html#json-messages&gt; for more</tspan>
</tspan>
<tspan x="10px" y="3736px"><tspan> details. Conflicts with </tspan><tspan class="bold">human and short.</tspan>
</tspan>
<tspan x="10px" y="3754px">
</tspan>
<tspan x="10px" y="3772px"><tspan class="bold"> • json-diagnostic-short: Ensure the rendered field of JSON messages contains the “short”</tspan>
</tspan>
<tspan x="10px" y="3790px"><tspan class="bold"> rendering from rustc. Cannot be used with human or short.</tspan>
</tspan>
<tspan x="10px" y="3808px">
</tspan>
<tspan x="10px" y="3826px"><tspan class="bold"> • json-diagnostic-rendered-ansi: Ensure the rendered field of JSON messages contains</tspan>
</tspan>
<tspan x="10px" y="3844px"><tspan class="bold"> embedded ANSI color codes for respecting rustc’s default color scheme. Cannot be used</tspan>
</tspan>
<tspan x="10px" y="3862px"><tspan class="bold"> with human or short.</tspan>
</tspan>
<tspan x="10px" y="3880px">
</tspan>
<tspan x="10px" y="3898px"><tspan class="bold"> • json-render-diagnostics: Instruct Cargo to not include rustc diagnostics in JSON</tspan>
</tspan>
<tspan x="10px" y="3916px"><tspan class="bold"> messages printed, but instead Cargo itself should render the JSON diagnostics coming</tspan>
</tspan>
<tspan x="10px" y="3934px"><tspan class="bold"> from rustc. Cargo’s own JSON diagnostics and others coming from rustc are still</tspan>
</tspan>
<tspan x="10px" y="3952px"><tspan class="bold"> emitted. Cannot be used with human or short.</tspan>
</tspan>
<tspan x="10px" y="3970px">
</tspan>
<tspan x="10px" y="3988px"><tspan class="bold"> --build-plan</tspan>
</tspan>
<tspan x="10px" y="4006px"><tspan> Outputs a series of JSON messages to stdout that indicate the commands to run the build.</tspan>
</tspan>
<tspan x="10px" y="4024px">
</tspan>
<tspan x="10px" y="4042px"><tspan> This option is unstable and available only on the </tspan><tspan class="underline">nightly channel</tspan>
</tspan>
<tspan x="10px" y="4060px"><tspan> &lt;https://doc.rust-lang.org/book/appendix-07-nightly-rust.html&gt; and requires the </tspan><tspan class="bold">-Z</tspan>
</tspan>
<tspan x="10px" y="4078px"><tspan> </tspan><tspan class="bold">unstable-options flag to enable. See &lt;https://github.com/rust-lang/cargo/issues/5579&gt; for</tspan>
</tspan>
<tspan x="10px" y="4096px"><tspan class="bold"> more information.</tspan>
</tspan>
<tspan x="10px" y="4114px">
</tspan>
<tspan x="10px" y="4132px"><tspan class="bold"> Manifest Options</tspan>
</tspan>
<tspan x="10px" y="4150px"><tspan> </tspan><tspan class="bold">--manifest-path </tspan><tspan class="underline bold">path</tspan>
</tspan>
<tspan x="10px" y="4168px"><tspan> Path to the </tspan><tspan class="bold">Cargo.toml file. By default, Cargo searches for the Cargo.toml file in the</tspan>
</tspan>
<tspan x="10px" y="4186px"><tspan class="bold"> current directory or any parent directory.</tspan>
</tspan>
<tspan x="10px" y="4204px">
</tspan>
<tspan x="10px" y="4222px"><tspan class="bold"> --ignore-rust-version</tspan>
</tspan>
<tspan x="10px" y="4240px"><tspan> Ignore </tspan><tspan class="bold">rust-version specification in packages.</tspan>
</tspan>
<tspan x="10px" y="4258px">
</tspan>
<tspan x="10px" y="4276px"><tspan class="bold"> --locked</tspan>
</tspan>
<tspan x="10px" y="4294px"><tspan> Asserts that the exact same dependencies and versions are used as when the existing</tspan>
</tspan>
<tspan x="10px" y="4312px"><tspan> </tspan><tspan class="bold">Cargo.lock file was originally generated. Cargo will exit with an error when either of the</tspan>
</tspan>
<tspan x="10px" y="4330px"><tspan class="bold"> following scenarios arises:</tspan>
</tspan>
<tspan x="10px" y="4348px">
</tspan>
<tspan x="10px" y="4366px"><tspan class="bold"> • The lock file is missing.</tspan>
</tspan>
<tspan x="10px" y="4384px">
</tspan>
<tspan x="10px" y="4402px"><tspan class="bold"> • Cargo attempted to change the lock file due to a different dependency resolution.</tspan>
</tspan>
<tspan x="10px" y="4420px">
</tspan>
<tspan x="10px" y="4438px"><tspan class="bold"> It may be used in environments where deterministic builds are desired, such as in CI</tspan>
</tspan>
<tspan x="10px" y="4456px"><tspan class="bold"> pipelines.</tspan>
</tspan>
<tspan x="10px" y="4474px">
</tspan>
<tspan x="10px" y="4492px"><tspan class="bold"> --offline</tspan>
</tspan>
<tspan x="10px" y="4510px"><tspan> Prevents Cargo from accessing the network for any reason. Without this flag, Cargo will</tspan>
</tspan>
<tspan x="10px" y="4528px"><tspan> stop with an error if it needs to access the network and the network is not available.</tspan>
</tspan>
<tspan x="10px" y="4546px"><tspan> With this flag, Cargo will attempt to proceed without the network if possible.</tspan>
</tspan>
<tspan x="10px" y="4564px">
</tspan>
<tspan x="10px" y="4582px"><tspan> Beware that this may result in different dependency resolution than online mode. Cargo</tspan>
</tspan>
<tspan x="10px" y="4600px"><tspan> will restrict itself to crates that are downloaded locally, even if there might be a newer</tspan>
</tspan>
<tspan x="10px" y="4618px"><tspan> version as indicated in the local copy of the index. See the </tspan><tspan class="bold">cargo-fetch(1) command to</tspan>
</tspan>
<tspan x="10px" y="4636px"><tspan class="bold"> download dependencies before going offline.</tspan>
</tspan>
<tspan x="10px" y="4654px">
</tspan>
<tspan x="10px" y="4672px"><tspan class="bold"> May also be specified with the net.offline </tspan><tspan class="underline bold">config value</tspan>
</tspan>
<tspan x="10px" y="4690px"><tspan> &lt;https://doc.rust-lang.org/cargo/reference/config.html&gt;.</tspan>
</tspan>
<tspan x="10px" y="4708px">
</tspan>
<tspan x="10px" y="4726px"><tspan> </tspan><tspan class="bold">--frozen</tspan>
</tspan>
<tspan x="10px" y="4744px"><tspan> Equivalent to specifying both </tspan><tspan class="bold">--locked and --offline.</tspan>
</tspan>
<tspan x="10px" y="4762px">
</tspan>
<tspan x="10px" y="4780px"><tspan class="bold"> --lockfile-path </tspan><tspan class="underline bold">PATH</tspan>
</tspan>
<tspan x="10px" y="4798px"><tspan> Changes the path of the lockfile from the default (</tspan><tspan class="bold">&lt;workspace_root&gt;/Cargo.lock) to </tspan><tspan class="underline bold">PATH.</tspan>
</tspan>
<tspan x="10px" y="4816px"><tspan class="underline bold"> PATH must end with Cargo.lock (e.g. --lockfile-path /tmp/temporary-lockfile/Cargo.lock).</tspan>
</tspan>
<tspan x="10px" y="4834px"><tspan class="underline bold"> Note that providing --lockfile-path will ignore existing lockfile at the default path, and</tspan>
</tspan>
<tspan x="10px" y="4852px"><tspan class="underline bold"> instead will either use the lockfile from PATH, or write a new lockfile into the provided</tspan>
</tspan>
<tspan x="10px" y="4870px"><tspan class="underline bold"> PATH if it doesn’t exist. This flag can be used to run most commands in read-only</tspan>
</tspan>
<tspan x="10px" y="4888px"><tspan class="underline bold"> directories, writing lockfile into the provided PATH.</tspan>
</tspan>
<tspan x="10px" y="4906px">
</tspan>
<tspan x="10px" y="4924px"><tspan class="underline bold"> This option is only available on the nightly channel</tspan>
</tspan>
<tspan x="10px" y="4942px"><tspan> &lt;https://doc.rust-lang.org/book/appendix-07-nightly-rust.html&gt; and requires the </tspan><tspan class="bold">-Z</tspan>
</tspan>
<tspan x="10px" y="4960px"><tspan> </tspan><tspan class="bold">unstable-options flag to enable (see </tspan><tspan class="underline bold">#14421</tspan>
</tspan>
<tspan x="10px" y="4978px"><tspan> &lt;https://github.com/rust-lang/cargo/issues/14421&gt;).</tspan>
</tspan>
<tspan x="10px" y="4996px">
</tspan>
<tspan x="10px" y="5014px"><tspan> </tspan><tspan class="bold">Common Options</tspan>
</tspan>
<tspan x="10px" y="5032px"><tspan> </tspan><tspan class="bold">+</tspan><tspan class="underline bold">toolchain</tspan>
</tspan>
<tspan x="10px" y="5050px"><tspan> If Cargo has been installed with rustup, and the first argument to </tspan><tspan class="bold">cargo begins with +, it</tspan>
</tspan>
<tspan x="10px" y="5068px"><tspan class="bold"> will be interpreted as a rustup toolchain name (such as +stable or +nightly). See the</tspan>
</tspan>
<tspan x="10px" y="5086px"><tspan class="bold"> </tspan><tspan class="underline bold">rustup documentation &lt;https://rust-lang.github.io/rustup/overrides.html&gt; for more</tspan>
</tspan>
<tspan x="10px" y="5104px"><tspan class="underline bold"> information about how toolchain overrides work.</tspan>
</tspan>
<tspan x="10px" y="5122px">
</tspan>
<tspan x="10px" y="5140px"><tspan class="underline bold"> --config KEY=VALUE or PATH</tspan>
</tspan>
<tspan x="10px" y="5158px"><tspan> Overrides a Cargo configuration value. The argument should be in TOML syntax of </tspan><tspan class="bold">KEY=VALUE,</tspan>
</tspan>
<tspan x="10px" y="5176px"><tspan class="bold"> or provided as a path to an extra configuration file. This flag may be specified multiple</tspan>
</tspan>
<tspan x="10px" y="5194px"><tspan class="bold"> times. See the </tspan><tspan class="underline bold">command-line overrides section</tspan>
</tspan>
<tspan x="10px" y="5212px"><tspan> &lt;https://doc.rust-lang.org/cargo/reference/config.html#command-line-overrides&gt; for more</tspan>
</tspan>
<tspan x="10px" y="5230px"><tspan> information.</tspan>
</tspan>
<tspan x="10px" y="5248px">
</tspan>
<tspan x="10px" y="5266px"><tspan> </tspan><tspan class="bold">-C </tspan><tspan class="underline bold">PATH</tspan>
</tspan>
<tspan x="10px" y="5284px"><tspan> Changes the current working directory before executing any specified operations. This</tspan>
</tspan>
<tspan x="10px" y="5302px"><tspan> affects things like where cargo looks by default for the project manifest (</tspan><tspan class="bold">Cargo.toml), as</tspan>
</tspan>
<tspan x="10px" y="5320px"><tspan class="bold"> well as the directories searched for discovering .cargo/config.toml, for example. This</tspan>
</tspan>
<tspan x="10px" y="5338px"><tspan class="bold"> option must appear before the command name, for example cargo -C path/to/my-project build.</tspan>
</tspan>
<tspan x="10px" y="5356px">
</tspan>
<tspan x="10px" y="5374px"><tspan class="bold"> This option is only available on the </tspan><tspan class="underline bold">nightly channel</tspan>
</tspan>
<tspan x="10px" y="5392px"><tspan> &lt;https://doc.rust-lang.org/book/appendix-07-nightly-rust.html&gt; and requires the </tspan><tspan class="bold">-Z</tspan>
</tspan>
<tspan x="10px" y="5410px"><tspan> </tspan><tspan class="bold">unstable-options flag to enable (see </tspan><tspan class="underline bold">#10098</tspan>
</tspan>
<tspan x="10px" y="5428px"><tspan> &lt;https://github.com/rust-lang/cargo/issues/10098&gt;).</tspan>
</tspan>
<tspan x="10px" y="5446px">
</tspan>
<tspan x="10px" y="5464px"><tspan> </tspan><tspan class="bold">-h, --help</tspan>
</tspan>
<tspan x="10px" y="5482px"><tspan> Prints help information.</tspan>
</tspan>
<tspan x="10px" y="5500px">
</tspan>
<tspan x="10px" y="5518px"><tspan> </tspan><tspan class="bold">-Z </tspan><tspan class="underline bold">flag</tspan>
</tspan>
<tspan x="10px" y="5536px"><tspan> Unstable (nightly-only) flags to Cargo. Run </tspan><tspan class="bold">cargo -Z help for details.</tspan>
</tspan>
<tspan x="10px" y="5554px">
</tspan>
<tspan x="10px" y="5572px"><tspan class="bold"> Miscellaneous Options</tspan>
</tspan>
<tspan x="10px" y="5590px"><tspan> </tspan><tspan class="bold">-j </tspan><tspan class="underline bold">N, --jobs N</tspan>
</tspan>
<tspan x="10px" y="5608px"><tspan> Number of parallel jobs to run. May also be specified with the </tspan><tspan class="bold">build.jobs </tspan><tspan class="underline bold">config value</tspan>
</tspan>
<tspan x="10px" y="5626px"><tspan> &lt;https://doc.rust-lang.org/cargo/reference/config.html&gt;. Defaults to the number of logical</tspan>
</tspan>
<tspan x="10px" y="5644px"><tspan> CPUs. If negative, it sets the maximum number of parallel jobs to the number of logical</tspan>
</tspan>
<tspan x="10px" y="5662px"><tspan> CPUs plus provided value. If a string </tspan><tspan class="bold">default is provided, it sets the value back to</tspan>
</tspan>
<tspan x="10px" y="5680px"><tspan class="bold"> defaults. Should not be 0.</tspan>
</tspan>
<tspan x="10px" y="5698px">
</tspan>
<tspan x="10px" y="5716px"><tspan class="bold"> --keep-going</tspan>
</tspan>
<tspan x="10px" y="5734px"><tspan> Build as many crates in the dependency graph as possible, rather than aborting the build</tspan>
</tspan>
<tspan x="10px" y="5752px"><tspan> on the first one that fails to build.</tspan>
</tspan>
<tspan x="10px" y="5770px">
</tspan>
<tspan x="10px" y="5788px"><tspan> For example if the current package depends on dependencies </tspan><tspan class="bold">fails and works, one of which</tspan>
</tspan>
<tspan x="10px" y="5806px"><tspan class="bold"> fails to build, cargo build -j1 may or may not build the one that succeeds (depending on</tspan>
</tspan>
<tspan x="10px" y="5824px"><tspan class="bold"> which one of the two builds Cargo picked to run first), whereas cargo build -j1</tspan>
</tspan>
<tspan x="10px" y="5842px"><tspan> </tspan><tspan class="bold">--keep-going would definitely run both builds, even if the one run first fails.</tspan>
</tspan>
<tspan x="10px" y="5860px">
</tspan>
<tspan x="10px" y="5878px"><tspan class="bold"> --future-incompat-report</tspan>
</tspan>
<tspan x="10px" y="5896px"><tspan> Displays a future-incompat report for any future-incompatible warnings produced during</tspan>
</tspan>
<tspan x="10px" y="5914px"><tspan> execution of this command</tspan>
</tspan>
<tspan x="10px" y="5932px">
</tspan>
<tspan x="10px" y="5950px"><tspan> See </tspan><tspan class="bold">cargo-report(1)</tspan>
</tspan>
<tspan x="10px" y="5968px">
</tspan>
<tspan x="10px" y="5986px"><tspan class="bold">ENVIRONMENT</tspan>
</tspan>
<tspan x="10px" y="6004px"><tspan> See </tspan><tspan class="underline">the reference &lt;https://doc.rust-lang.org/cargo/reference/environment-variables.html&gt; for</tspan>
</tspan>
<tspan x="10px" y="6022px"><tspan class="underline"> details on environment variables that Cargo reads.</tspan>
</tspan>
<tspan x="10px" y="6040px">
</tspan>
<tspan x="10px" y="6058px"><tspan class="underline bold">EXIT STATUS</tspan>
</tspan>
<tspan x="10px" y="6076px"><tspan> • </tspan><tspan class="bold">0: Cargo succeeded.</tspan>
</tspan>
<tspan x="10px" y="6094px">
</tspan>
<tspan x="10px" y="6112px"><tspan class="bold"> • 101: Cargo failed to complete.</tspan>
</tspan>
<tspan x="10px" y="6130px">
</tspan>
<tspan x="10px" y="6148px"><tspan class="bold">EXAMPLES</tspan>
</tspan>
<tspan x="10px" y="6166px"><tspan> 1. Build the local package and all of its dependencies:</tspan>
</tspan>
<tspan x="10px" y="6184px">
</tspan>
<tspan x="10px" y="6202px"><tspan> cargo build</tspan>
</tspan>
<tspan x="10px" y="6220px">
</tspan>
<tspan x="10px" y="6238px"><tspan> 2. Build with optimizations:</tspan>
</tspan>
<tspan x="10px" y="6256px">
</tspan>
<tspan x="10px" y="6274px"><tspan> cargo build --release</tspan>
</tspan>
<tspan x="10px" y="6292px">
</tspan>
<tspan x="10px" y="6310px"><tspan class="bold">SEE ALSO</tspan>
</tspan>
<tspan x="10px" y="6328px"><tspan> </tspan><tspan class="bold">cargo(1), cargo-rustc(1)</tspan>
</tspan>
<tspan x="10px" y="6346px">
</tspan>
<tspan x="10px" y="6364px"><tspan class="bold"> </tspan><tspan class="underline bold">CARGO-BUILD(1)</tspan>
</tspan>
<tspan x="10px" y="6382px">
</tspan>
</text>
</svg>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment