3 This document explains how Cargo’s configuration system works, as well as
4 available keys or configuration. For configuration of a package through its
5 manifest, see the [manifest format](manifest.md).
7 ### Hierarchical structure
9 Cargo allows local configuration for a particular package as well as global
10 configuration. It looks for configuration files in the current directory and
11 all parent directories. If, for example, Cargo were invoked in
12 `/projects/foo/bar/baz`, then the following configuration files would be
13 probed for and unified in this order:
15 * `/projects/foo/bar/baz/.cargo/config.toml`
16 * `/projects/foo/bar/.cargo/config.toml`
17 * `/projects/foo/.cargo/config.toml`
18 * `/projects/.cargo/config.toml`
19 * `/.cargo/config.toml`
20 * `$CARGO_HOME/config.toml` which defaults to:
21 * Windows: `%USERPROFILE%\.cargo\config.toml`
22 * Unix: `$HOME/.cargo/config.toml`
24 With this structure, you can specify configuration per-package, and even
25 possibly check it into version control. You can also specify personal defaults
26 with a configuration file in your home directory.
28 If a key is specified in multiple config files, the values will get merged
29 together. Numbers, strings, and booleans will use the value in the deeper
30 config directory taking precedence over ancestor directories, where the
31 home directory is the lowest priority. Arrays will be joined together.
33 At present, when being invoked from a workspace, Cargo does not read config
34 files from crates within the workspace. i.e. if a workspace has two crates in
35 it, named `/projects/foo/bar/baz/mylib` and `/projects/foo/bar/baz/mybin`, and
36 there are Cargo configs at `/projects/foo/bar/baz/mylib/.cargo/config.toml`
37 and `/projects/foo/bar/baz/mybin/.cargo/config.toml`, Cargo does not read
38 those configuration files if it is invoked from the workspace root
39 (`/projects/foo/bar/baz/`).
41 > **Note:** Cargo also reads config files without the `.toml` extension, such as
42 > `.cargo/config`. Support for the `.toml` extension was added in version 1.39
43 > and is the preferred form. If both files exist, Cargo will use the file
44 > without the extension.
46 ### Configuration format
48 Configuration files are written in the [TOML format][toml] (like the
49 manifest), with simple key-value pairs inside of sections (tables). The
50 following is a quick overview of all settings, with detailed descriptions
54 paths = ["/path/to/override"] # path dependency overrides
56 [alias] # command aliases
62 space_example = ["run", "--release", "--", "\"command list\""]
65 jobs = 1 # number of parallel jobs, defaults to # of CPUs
66 rustc = "rustc" # the rust compiler tool
67 rustc-wrapper = "…" # run this wrapper instead of `rustc`
68 rustc-workspace-wrapper = "…" # run this wrapper instead of `rustc` for workspace members
69 rustdoc = "rustdoc" # the doc generator tool
70 target = "triple" # build for the target triple (ignored by `cargo install`)
71 target-dir = "target" # path of where to place all generated artifacts
72 rustflags = ["…", "…"] # custom flags to pass to all compiler invocations
73 rustdocflags = ["…", "…"] # custom flags to pass to rustdoc
74 incremental = true # whether or not to enable incremental compilation
75 dep-info-basedir = "…" # path for the base directory for targets in depfiles
76 pipelining = true # rustc pipelining
79 browser = "chromium" # browser to use with `cargo doc --open`,
80 # overrides the `BROWSER` environment variable
83 # Set ENV_VAR_NAME=value for any process run by Cargo
84 ENV_VAR_NAME = "value"
85 # Set even if already present in environment
86 ENV_VAR_NAME_2 = { value = "value", force = true }
87 # Value is relative to .cargo directory containing `config.toml`, make absolute
88 ENV_VAR_NAME_3 = { value = "relative/path", relative = true }
91 vcs = "none" # VCS to use ('git', 'hg', 'pijul', 'fossil', 'none')
94 debug = false # HTTP debugging
95 proxy = "host:port" # HTTP proxy in libcurl format
96 ssl-version = "tlsv1.3" # TLS version to use
97 ssl-version.max = "tlsv1.3" # maximum TLS version
98 ssl-version.min = "tlsv1.1" # minimum TLS version
99 timeout = 30 # timeout for each HTTP request, in seconds
100 low-speed-limit = 10 # network timeout threshold (bytes/sec)
101 cainfo = "cert.pem" # path to Certificate Authority (CA) bundle
102 check-revoke = true # check for SSL certificate revocation
103 multiplexing = true # HTTP/2 multiplexing
104 user-agent = "…" # the user-agent header
107 root = "/some/path" # `cargo install` destination directory
110 retry = 2 # network retries
111 git-fetch-with-cli = true # use the `git` executable for git operations
112 offline = false # do not access the network
115 # Same keys as for [patch] in Cargo.toml
117 [profile.<name>] # Modify profile settings via config.
118 opt-level = 0 # Optimization level.
119 debug = true # Include debug info.
120 split-debuginfo = '...' # Debug info splitting behavior.
121 debug-assertions = true # Enables debug assertions.
122 overflow-checks = true # Enables runtime integer overflow checks.
123 lto = false # Sets link-time optimization.
124 panic = 'unwind' # The panic strategy.
125 incremental = true # Incremental compilation.
126 codegen-units = 16 # Number of code generation units.
127 rpath = false # Sets the rpath linking option.
128 [profile.<name>.build-override] # Overrides build-script settings.
129 # Same keys for a normal profile.
130 [profile.<name>.package.<name>] # Override profile for a package.
131 # Same keys for a normal profile (minus `panic`, `lto`, and `rpath`).
133 [registries.<name>] # registries other than crates.io
134 index = "…" # URL of the registry index
135 token = "…" # authentication token for the registry
138 default = "…" # name of the default registry
139 token = "…" # authentication token for crates.io
141 [source.<name>] # source definition and replacement
142 replace-with = "…" # replace this source with the given named source
143 directory = "…" # path to a directory source
144 registry = "…" # URL to a registry source
145 local-registry = "…" # path to a local registry source
146 git = "…" # URL of a git repository source
147 branch = "…" # branch name for the git repository
148 tag = "…" # tag name for the git repository
149 rev = "…" # revision for the git repository
152 linker = "…" # linker to use
153 runner = "…" # wrapper to run executables
154 rustflags = ["…", "…"] # custom flags for `rustc`
157 runner = "…" # wrapper to run executables
158 rustflags = ["…", "…"] # custom flags for `rustc`
160 [target.<triple>.<links>] # `links` build script override
161 rustc-link-lib = ["foo"]
162 rustc-link-search = ["/path/to/foo"]
163 rustc-flags = ["-L", "/some/path"]
164 rustc-cfg = ['key="value"']
165 rustc-env = {key = "value"}
166 rustc-cdylib-link-arg = ["…"]
167 metadata_key1 = "value"
168 metadata_key2 = "value"
171 verbose = false # whether cargo provides verbose output
172 color = 'auto' # whether cargo colorizes output
173 progress.when = 'auto' # whether cargo shows progress bar
174 progress.width = 80 # width of progress bar
177 ### Environment variables
179 Cargo can also be configured through environment variables in addition to the
180 TOML configuration files. For each configuration key of the form `foo.bar` the
181 environment variable `CARGO_FOO_BAR` can also be used to define the value.
182 Keys are converted to uppercase, dots and dashes are converted to underscores.
183 For example the `target.x86_64-unknown-linux-gnu.runner` key can also be
184 defined by the `CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER` environment
187 Environment variables will take precedence over TOML configuration files.
188 Currently only integer, boolean, string and some array values are supported to
189 be defined by environment variables. Descriptions below indicate which keys
190 support environment variables.
192 In addition to the system above, Cargo recognizes a few other specific
193 [environment variables][env].
195 ### Config-relative paths
197 Paths in config files may be absolute, relative, or a bare name without any
198 path separators. Paths for executables without a path separator will use the
199 `PATH` environment variable to search for the executable. Paths for
200 non-executables will be relative to where the config value is defined. For
201 config files, that is relative to the parent directory of the `.cargo`
202 directory where the value was defined. For environment variables it is
203 relative to the current working directory.
206 # Relative path examples.
208 [target.x86_64-unknown-linux-gnu]
209 runner = "foo" # Searches `PATH` for `foo`.
211 [source.vendored-sources]
212 # Directory is relative to the parent where `.cargo/config.toml` is located.
213 # For example, `/my/project/.cargo/config.toml` would result in `/my/project/vendor`.
217 ### Executable paths with arguments
219 Some Cargo commands invoke external programs, which can be configured as a path
220 and some number of arguments.
222 The value may be an array of strings like `['/path/to/program', 'somearg']` or
223 a space-separated string like `'/path/to/program somearg'`. If the path to the
224 executable contains a space, the list form must be used.
226 If Cargo is passing other arguments to the program such as a path to open or
227 run, they will be passed after the last specified argument in the value of an
228 option of this format. If the specified program does not have path separators,
229 Cargo will search `PATH` for its executable.
233 Configuration values with sensitive information are stored in the
234 `$CARGO_HOME/credentials.toml` file. This file is automatically created and updated
235 by [`cargo login`]. It follows the same format as Cargo config files.
239 token = "…" # Access token for crates.io
242 token = "…" # Access token for the named registry
245 Tokens are used by some Cargo commands such as [`cargo publish`] for
246 authenticating with remote registries. Care should be taken to protect the
247 tokens and to keep them secret.
249 As with most other config values, tokens may be specified with environment
250 variables. The token for [crates.io] may be specified with the
251 `CARGO_REGISTRY_TOKEN` environment variable. Tokens for other registries may
252 be specified with environment variables of the form
253 `CARGO_REGISTRIES_<name>_TOKEN` where `<name>` is the name of the registry in
256 ### Configuration keys
258 This section documents all configuration keys. The description for keys with
259 variable parts are annotated with angled brackets like `target.<triple>` where
260 the `<triple>` part can be any target triple like
261 `target.x86_64-pc-windows-msvc`.
264 * Type: array of strings (paths)
266 * Environment: not supported
268 An array of paths to local packages which are to be used as overrides for
269 dependencies. For more information see the [Overriding Dependencies
270 guide](overriding-dependencies.md#paths-overrides).
273 * Type: string or array of strings
275 * Environment: `CARGO_ALIAS_<name>`
277 The `[alias]` table defines CLI command aliases. For example, running `cargo
278 b` is an alias for running `cargo build`. Each key in the table is the
279 subcommand, and the value is the actual command to run. The value may be an
280 array of strings, where the first element is the command and the following are
281 arguments. It may also be a string, which will be split on spaces into
282 subcommand and arguments. The following aliases are built-in to Cargo:
293 Aliases are not allowed to redefine existing built-in commands.
297 The `[build]` table controls build-time operations and compiler settings.
301 * Default: number of logical CPUs
302 * Environment: `CARGO_BUILD_JOBS`
304 Sets the maximum number of compiler processes to run in parallel.
306 Can be overridden with the `--jobs` CLI option.
309 * Type: string (program path)
311 * Environment: `CARGO_BUILD_RUSTC` or `RUSTC`
313 Sets the executable to use for `rustc`.
315 ##### `build.rustc-wrapper`
316 * Type: string (program path)
318 * Environment: `CARGO_BUILD_RUSTC_WRAPPER` or `RUSTC_WRAPPER`
320 Sets a wrapper to execute instead of `rustc`. The first argument passed to the
321 wrapper is the path to the actual `rustc`.
323 ##### `build.rustc-workspace-wrapper`
324 * Type: string (program path)
326 * Environment: `CARGO_BUILD_RUSTC_WORKSPACE_WRAPPER` or `RUSTC_WORKSPACE_WRAPPER`
328 Sets a wrapper to execute instead of `rustc`, for workspace members only.
329 The first argument passed to the wrapper is the path to the actual `rustc`.
330 It affects the filename hash so that artifacts produced by the wrapper are cached separately.
332 ##### `build.rustdoc`
333 * Type: string (program path)
335 * Environment: `CARGO_BUILD_RUSTDOC` or `RUSTDOC`
337 Sets the executable to use for `rustdoc`.
341 * Default: host platform
342 * Environment: `CARGO_BUILD_TARGET`
344 The default target platform triple to compile to.
346 This may also be a relative path to a `.json` target spec file.
348 Can be overridden with the `--target` CLI option.
350 ##### `build.target-dir`
351 * Type: string (path)
353 * Environment: `CARGO_BUILD_TARGET_DIR` or `CARGO_TARGET_DIR`
355 The path to where all compiler output is placed. The default if not specified
356 is a directory named `target` located at the root of the workspace.
358 Can be overridden with the `--target-dir` CLI option.
360 ##### `build.rustflags`
361 * Type: string or array of strings
363 * Environment: `CARGO_BUILD_RUSTFLAGS` or `RUSTFLAGS`
365 Extra command-line flags to pass to `rustc`. The value may be a array of
366 strings or a space-separated string.
368 There are three mutually exclusive sources of extra flags. They are checked in
369 order, with the first one being used:
371 1. `RUSTFLAGS` environment variable.
372 2. All matching `target.<triple>.rustflags` and `target.<cfg>.rustflags`
373 config entries joined together.
374 3. `build.rustflags` config value.
376 Additional flags may also be passed with the [`cargo rustc`] command.
378 If the `--target` flag (or [`build.target`](#buildtarget)) is used, then the
379 flags will only be passed to the compiler for the target. Things being built
380 for the host, such as build scripts or proc macros, will not receive the args.
381 Without `--target`, the flags will be passed to all compiler invocations
382 (including build scripts and proc macros) because dependencies are shared. If
383 you have args that you do not want to pass to build scripts or proc macros and
384 are building for the host, pass `--target` with the host triple.
386 It is not recommended to pass in flags that Cargo itself usually manages. For
387 example, the flags driven by [profiles] are best handled by setting the
388 appropriate profile setting.
390 > **Caution**: Due to the low-level nature of passing flags directly to the
391 > compiler, this may cause a conflict with future versions of Cargo which may
392 > issue the same or similar flags on its own which may interfere with the
393 > flags you specify. This is an area where Cargo may not always be backwards
396 ##### `build.rustdocflags`
397 * Type: string or array of strings
399 * Environment: `CARGO_BUILD_RUSTDOCFLAGS` or `RUSTDOCFLAGS`
401 Extra command-line flags to pass to `rustdoc`. The value may be a array of
402 strings or a space-separated string.
404 There are two mutually exclusive sources of extra flags. They are checked in
405 order, with the first one being used:
407 1. `RUSTDOCFLAGS` environment variable.
408 2. `build.rustdocflags` config value.
410 Additional flags may also be passed with the [`cargo rustdoc`] command.
412 ##### `build.incremental`
414 * Default: from profile
415 * Environment: `CARGO_BUILD_INCREMENTAL` or `CARGO_INCREMENTAL`
417 Whether or not to perform [incremental compilation]. The default if not set is
418 to use the value from the [profile]. Otherwise this overrides the setting of
421 The `CARGO_INCREMENTAL` environment variable can be set to `1` to force enable
422 incremental compilation for all profiles, or `0` to disable it. This env var
423 overrides the config setting.
425 ##### `build.dep-info-basedir`
426 * Type: string (path)
428 * Environment: `CARGO_BUILD_DEP_INFO_BASEDIR`
430 Strips the given path prefix from [dep
431 info](../guide/build-cache.md#dep-info-files) file paths. This config setting
432 is intended to convert absolute paths to relative paths for tools that require
435 The setting itself is a config-relative path. So, for example, a value of
436 `"."` would strip all paths starting with the parent directory of the `.cargo`
439 ##### `build.pipelining`
442 * Environment: `CARGO_BUILD_PIPELINING`
444 Controls whether or not build pipelining is used. This allows Cargo to
445 schedule overlapping invocations of `rustc` in parallel when possible.
449 The `[doc]` table defines options for the [`cargo doc`] command.
453 * Type: string or array of strings ([program path and args])
454 * Default: `BROWSER` environment variable, or, if that is missing,
455 opening the link in a system specific way
457 This option sets the browser to be used by [`cargo doc`], overriding the
458 `BROWSER` environment variable when opening documentation with the `--open`
463 The `[cargo-new]` table defines defaults for the [`cargo new`] command.
465 ##### `cargo-new.name`
467 This option is deprecated and unused.
469 ##### `cargo-new.email`
471 This option is deprecated and unused.
473 ##### `cargo-new.vcs`
475 * Default: "git" or "none"
476 * Environment: `CARGO_CARGO_NEW_VCS`
478 Specifies the source control system to use for initializing a new repository.
479 Valid values are `git`, `hg` (for Mercurial), `pijul`, `fossil` or `none` to
480 disable this behavior. Defaults to `git`, or `none` if already inside a VCS
481 repository. Can be overridden with the `--vcs` CLI option.
485 The `[env]` section allows you to set additional environment variables for
486 build scripts, rustc invocations, `cargo run` and `cargo build`.
490 OPENSSL_DIR = "/opt/openssl"
493 By default, the variables specified will not override values that already exist
494 in the environment. This behavior can be changed by setting the `force` flag.
496 Setting the `relative` flag evaluates the value as a config-relative path that
497 is relative to the parent directory of the `.cargo` directory that contains the
498 `config.toml` file. The value of the environment variable will be the full
503 TMPDIR = { value = "/home/tmp", force = true }
504 OPENSSL_DIR = { value = "vendor/openssl", relative = true }
509 The `[http]` table defines settings for HTTP behavior. This includes fetching
510 crate dependencies and accessing remote git repositories.
515 * Environment: `CARGO_HTTP_DEBUG`
517 If `true`, enables debugging of HTTP requests. The debug information can be
518 seen by setting the `CARGO_LOG=cargo::ops::registry=debug` environment
519 variable (or use `trace` for even more information).
521 Be wary when posting logs from this output in a public location. The output
522 may include headers with authentication tokens which you don't want to leak!
523 Be sure to review logs before posting them.
528 * Environment: `CARGO_HTTP_PROXY` or `HTTPS_PROXY` or `https_proxy` or `http_proxy`
530 Sets an HTTP and HTTPS proxy to use. The format is in [libcurl format] as in
531 `[protocol://]host[:port]`. If not set, Cargo will also check the `http.proxy`
532 setting in your global git configuration. If none of those are set, the
533 `HTTPS_PROXY` or `https_proxy` environment variables set the proxy for HTTPS
534 requests, and `http_proxy` sets it for HTTP requests.
539 * Environment: `CARGO_HTTP_TIMEOUT` or `HTTP_TIMEOUT`
541 Sets the timeout for each HTTP request, in seconds.
544 * Type: string (path)
546 * Environment: `CARGO_HTTP_CAINFO`
548 Path to a Certificate Authority (CA) bundle file, used to verify TLS
549 certificates. If not specified, Cargo attempts to use the system certificates.
551 ##### `http.check-revoke`
553 * Default: true (Windows) false (all others)
554 * Environment: `CARGO_HTTP_CHECK_REVOKE`
556 This determines whether or not TLS certificate revocation checks should be
557 performed. This only works on Windows.
559 ##### `http.ssl-version`
560 * Type: string or min/max table
562 * Environment: `CARGO_HTTP_SSL_VERSION`
564 This sets the minimum TLS version to use. It takes a string, with one of the
565 possible values of "default", "tlsv1", "tlsv1.0", "tlsv1.1", "tlsv1.2", or
568 This may alternatively take a table with two keys, `min` and `max`, which each
569 take a string value of the same kind that specifies the minimum and maximum
570 range of TLS versions to use.
572 The default is a minimum version of "tlsv1.0" and a max of the newest version
573 supported on your platform, typically "tlsv1.3".
575 ##### `http.low-speed-limit`
578 * Environment: `CARGO_HTTP_LOW_SPEED_LIMIT`
580 This setting controls timeout behavior for slow connections. If the average
581 transfer speed in bytes per second is below the given value for
582 [`http.timeout`](#httptimeout) seconds (default 30 seconds), then the
583 connection is considered too slow and Cargo will abort and retry.
585 ##### `http.multiplexing`
588 * Environment: `CARGO_HTTP_MULTIPLEXING`
590 When `true`, Cargo will attempt to use the HTTP2 protocol with multiplexing.
591 This allows multiple requests to use the same connection, usually improving
592 performance when fetching multiple files. If `false`, Cargo will use HTTP 1.1
595 ##### `http.user-agent`
597 * Default: Cargo's version
598 * Environment: `CARGO_HTTP_USER_AGENT`
600 Specifies a custom user-agent header to use. The default if not specified is a
601 string that includes Cargo's version.
605 The `[install]` table defines defaults for the [`cargo install`] command.
608 * Type: string (path)
609 * Default: Cargo's home directory
610 * Environment: `CARGO_INSTALL_ROOT`
612 Sets the path to the root directory for installing executables for [`cargo
613 install`]. Executables go into a `bin` directory underneath the root.
615 The default if not specified is Cargo's home directory (default `.cargo` in
616 your home directory).
618 Can be overridden with the `--root` command-line option.
622 The `[net]` table controls networking configuration.
627 * Environment: `CARGO_NET_RETRY`
629 Number of times to retry possibly spurious network errors.
631 ##### `net.git-fetch-with-cli`
634 * Environment: `CARGO_NET_GIT_FETCH_WITH_CLI`
636 If this is `true`, then Cargo will use the `git` executable to fetch registry
637 indexes and git dependencies. If `false`, then it uses a built-in `git`
640 Setting this to `true` can be helpful if you have special authentication
641 requirements that Cargo does not support. See [Git
642 Authentication](../appendix/git-authentication.md) for more information about
643 setting up git authentication.
648 * Environment: `CARGO_NET_OFFLINE`
650 If this is `true`, then Cargo will avoid accessing the network, and attempt to
651 proceed with locally cached data. If `false`, Cargo will access the network as
652 needed, and generate an error if it encounters a network error.
654 Can be overridden with the `--offline` command-line option.
658 Just as you can override dependencies using [`[patch]` in
659 `Cargo.toml`](overriding-dependencies.md#the-patch-section), you can
660 override them in the cargo configuration file to apply those patches to
661 any affected build. The format is identical to the one used in
664 Since `.cargo/config.toml` files are not usually checked into source
665 control, you should prefer patching using `Cargo.toml` where possible to
666 ensure that other developers can compile your crate in their own
667 environments. Patching through cargo configuration files is generally
668 only appropriate when the patch section is automatically generated by an
671 If a given dependency is patched both in a cargo configuration file and
672 a `Cargo.toml` file, the patch in the configuration file is used. If
673 multiple configuration files patch the same dependency, standard cargo
674 configuration merging is used, which prefers the value defined closest
675 to the current directory, with `$HOME/.cargo/config.toml` taking the
678 Relative `path` dependencies in such a `[patch]` section are resolved
679 relative to the configuration file they appear in.
683 The `[profile]` table can be used to globally change profile settings, and
684 override settings specified in `Cargo.toml`. It has the same syntax and
685 options as profiles specified in `Cargo.toml`. See the [Profiles chapter] for
686 details about the options.
688 [Profiles chapter]: profiles.md
690 ##### `[profile.<name>.build-override]`
691 * Environment: `CARGO_PROFILE_<name>_BUILD_OVERRIDE_<key>`
693 The build-override table overrides settings for build scripts, proc macros,
694 and their dependencies. It has the same keys as a normal profile. See the
695 [overrides section](profiles.md#overrides) for more details.
697 ##### `[profile.<name>.package.<name>]`
698 * Environment: not supported
700 The package table overrides settings for specific packages. It has the same
701 keys as a normal profile, minus the `panic`, `lto`, and `rpath` settings. See
702 the [overrides section](profiles.md#overrides) for more details.
704 ##### `profile.<name>.codegen-units`
706 * Default: See profile docs.
707 * Environment: `CARGO_PROFILE_<name>_CODEGEN_UNITS`
709 See [codegen-units](profiles.md#codegen-units).
711 ##### `profile.<name>.debug`
712 * Type: integer or boolean
713 * Default: See profile docs.
714 * Environment: `CARGO_PROFILE_<name>_DEBUG`
716 See [debug](profiles.md#debug).
718 ##### `profile.<name>.split-debuginfo`
720 * Default: See profile docs.
721 * Environment: `CARGO_PROFILE_<name>_SPLIT_DEBUGINFO`
723 See [split-debuginfo](profiles.md#split-debuginfo).
725 ##### `profile.<name>.debug-assertions`
727 * Default: See profile docs.
728 * Environment: `CARGO_PROFILE_<name>_DEBUG_ASSERTIONS`
730 See [debug-assertions](profiles.md#debug-assertions).
732 ##### `profile.<name>.incremental`
734 * Default: See profile docs.
735 * Environment: `CARGO_PROFILE_<name>_INCREMENTAL`
737 See [incremental](profiles.md#incremental).
739 ##### `profile.<name>.lto`
740 * Type: string or boolean
741 * Default: See profile docs.
742 * Environment: `CARGO_PROFILE_<name>_LTO`
744 See [lto](profiles.md#lto).
746 ##### `profile.<name>.overflow-checks`
748 * Default: See profile docs.
749 * Environment: `CARGO_PROFILE_<name>_OVERFLOW_CHECKS`
751 See [overflow-checks](profiles.md#overflow-checks).
753 ##### `profile.<name>.opt-level`
754 * Type: integer or string
755 * Default: See profile docs.
756 * Environment: `CARGO_PROFILE_<name>_OPT_LEVEL`
758 See [opt-level](profiles.md#opt-level).
760 ##### `profile.<name>.panic`
762 * default: See profile docs.
763 * Environment: `CARGO_PROFILE_<name>_PANIC`
765 See [panic](profiles.md#panic).
767 ##### `profile.<name>.rpath`
769 * default: See profile docs.
770 * Environment: `CARGO_PROFILE_<name>_RPATH`
772 See [rpath](profiles.md#rpath).
777 The `[registries]` table is used for specifying additional [registries]. It
778 consists of a sub-table for each named registry.
780 ##### `registries.<name>.index`
783 * Environment: `CARGO_REGISTRIES_<name>_INDEX`
785 Specifies the URL of the git index for the registry.
787 ##### `registries.<name>.token`
790 * Environment: `CARGO_REGISTRIES_<name>_TOKEN`
792 Specifies the authentication token for the given registry. This value should
793 only appear in the [credentials](#credentials) file. This is used for registry
794 commands like [`cargo publish`] that require authentication.
796 Can be overridden with the `--token` command-line option.
800 The `[registry]` table controls the default registry used when one is not
803 ##### `registry.index`
805 This value is no longer accepted and should not be used.
807 ##### `registry.default`
809 * Default: `"crates-io"`
810 * Environment: `CARGO_REGISTRY_DEFAULT`
812 The name of the registry (from the [`registries` table](#registries)) to use
813 by default for registry commands like [`cargo publish`].
815 Can be overridden with the `--registry` command-line option.
817 ##### `registry.token`
820 * Environment: `CARGO_REGISTRY_TOKEN`
822 Specifies the authentication token for [crates.io]. This value should only
823 appear in the [credentials](#credentials) file. This is used for registry
824 commands like [`cargo publish`] that require authentication.
826 Can be overridden with the `--token` command-line option.
830 The `[source]` table defines the registry sources available. See [Source
831 Replacement] for more information. It consists of a sub-table for each named
832 source. A source should only define one kind (directory, registry,
833 local-registry, or git).
835 ##### `source.<name>.replace-with`
838 * Environment: not supported
840 If set, replace this source with the given named source.
842 ##### `source.<name>.directory`
843 * Type: string (path)
845 * Environment: not supported
847 Sets the path to a directory to use as a directory source.
849 ##### `source.<name>.registry`
852 * Environment: not supported
854 Sets the URL to use for a registry source.
856 ##### `source.<name>.local-registry`
857 * Type: string (path)
859 * Environment: not supported
861 Sets the path to a directory to use as a local registry source.
863 ##### `source.<name>.git`
866 * Environment: not supported
868 Sets the URL to use for a git repository source.
870 ##### `source.<name>.branch`
873 * Environment: not supported
875 Sets the branch name to use for a git repository.
877 If none of `branch`, `tag`, or `rev` is set, defaults to the `master` branch.
879 ##### `source.<name>.tag`
882 * Environment: not supported
884 Sets the tag name to use for a git repository.
886 If none of `branch`, `tag`, or `rev` is set, defaults to the `master` branch.
888 ##### `source.<name>.rev`
891 * Environment: not supported
893 Sets the [revision] to use for a git repository.
895 If none of `branch`, `tag`, or `rev` is set, defaults to the `master` branch.
900 The `[target]` table is used for specifying settings for specific platform
901 targets. It consists of a sub-table which is either a platform triple or a
902 [`cfg()` expression]. The given values will be used if the target platform
903 matches either the `<triple>` value or the `<cfg>` expression.
906 [target.thumbv7m-none-eabi]
907 linker = "arm-none-eabi-gcc"
908 runner = "my-emulator"
909 rustflags = ["…", "…"]
911 [target.'cfg(all(target_arch = "arm", target_os = "none"))']
912 runner = "my-arm-wrapper"
913 rustflags = ["…", "…"]
916 `cfg` values come from those built-in to the compiler (run `rustc --print=cfg`
917 to view), values set by [build scripts], and extra `--cfg` flags passed to
918 `rustc` (such as those defined in `RUSTFLAGS`). Do not try to match on
919 `debug_assertions` or Cargo features like `feature="foo"`.
921 If using a target spec JSON file, the `<triple>` value is the filename stem.
922 For example `--target foo/bar.json` would match `[target.bar]`.
924 ##### `target.<triple>.ar`
926 This option is deprecated and unused.
928 ##### `target.<triple>.linker`
929 * Type: string (program path)
931 * Environment: `CARGO_TARGET_<triple>_LINKER`
933 Specifies the linker which is passed to `rustc` (via [`-C linker`]) when the
934 `<triple>` is being compiled for. By default, the linker is not overridden.
936 ##### `target.<triple>.runner`
937 * Type: string or array of strings ([program path and args])
939 * Environment: `CARGO_TARGET_<triple>_RUNNER`
941 If a runner is provided, executables for the target `<triple>` will be
942 executed by invoking the specified runner with the actual executable passed as
943 an argument. This applies to [`cargo run`], [`cargo test`] and [`cargo bench`]
944 commands. By default, compiled executables are executed directly.
946 ##### `target.<cfg>.runner`
948 This is similar to the [target runner](#targettriplerunner), but using
949 a [`cfg()` expression]. If both a `<triple>` and `<cfg>` runner match,
950 the `<triple>` will take precedence. It is an error if more than one
951 `<cfg>` runner matches the current target.
953 ##### `target.<triple>.rustflags`
954 * Type: string or array of strings
956 * Environment: `CARGO_TARGET_<triple>_RUSTFLAGS`
958 Passes a set of custom flags to the compiler for this `<triple>`. The value
959 may be a array of strings or a space-separated string.
961 See [`build.rustflags`](#buildrustflags) for more details on the different
962 ways to specific extra flags.
964 ##### `target.<cfg>.rustflags`
966 This is similar to the [target rustflags](#targettriplerustflags), but
967 using a [`cfg()` expression]. If several `<cfg>` and `<triple>` entries
968 match the current target, the flags are joined together.
970 ##### `target.<triple>.<links>`
972 The links sub-table provides a way to [override a build script]. When
973 specified, the build script for the given `links` library will not be
974 run, and the given values will be used instead.
977 [target.x86_64-unknown-linux-gnu.foo]
978 rustc-link-lib = ["foo"]
979 rustc-link-search = ["/path/to/foo"]
980 rustc-flags = "-L /some/path"
981 rustc-cfg = ['key="value"']
982 rustc-env = {key = "value"}
983 rustc-cdylib-link-arg = ["…"]
984 metadata_key1 = "value"
985 metadata_key2 = "value"
990 The `[term]` table controls terminal output and interaction.
995 * Environment: `CARGO_TERM_VERBOSE`
997 Controls whether or not extra detailed messages are displayed by Cargo.
999 Specifying the `--quiet` flag will override and disable verbose output.
1000 Specifying the `--verbose` flag will override and force verbose output.
1005 * Environment: `CARGO_TERM_COLOR`
1007 Controls whether or not colored output is used in the terminal. Possible values:
1009 * `auto` (default): Automatically detect if color support is available on the
1011 * `always`: Always display colors.
1012 * `never`: Never display colors.
1014 Can be overridden with the `--color` command-line option.
1016 ##### `term.progress.when`
1019 * Environment: `CARGO_TERM_PROGRESS_WHEN`
1021 Controls whether or not progress bar is shown in the terminal. Possible values:
1023 * `auto` (default): Intelligently guess whether to show progress bar.
1024 * `always`: Always show progress bar.
1025 * `never`: Never show progress bar.
1027 ##### `term.progress.width`
1030 * Environment: `CARGO_TERM_PROGRESS_WIDTH`
1032 Sets the width for progress bar.
1034 [`cargo bench`]: ../commands/cargo-bench.md
1035 [`cargo login`]: ../commands/cargo-login.md
1036 [`cargo doc`]: ../commands/cargo-doc.md
1037 [`cargo new`]: ../commands/cargo-new.md
1038 [`cargo publish`]: ../commands/cargo-publish.md
1039 [`cargo run`]: ../commands/cargo-run.md
1040 [`cargo rustc`]: ../commands/cargo-rustc.md
1041 [`cargo test`]: ../commands/cargo-test.md
1042 [`cargo rustdoc`]: ../commands/cargo-rustdoc.md
1043 [`cargo install`]: ../commands/cargo-install.md
1044 [env]: environment-variables.md
1045 [`cfg()` expression]: ../../reference/conditional-compilation.html
1046 [build scripts]: build-scripts.md
1047 [`-C linker`]: ../../rustc/codegen-options/index.md#linker
1048 [override a build script]: build-scripts.md#overriding-build-scripts
1049 [toml]: https://toml.io/
1050 [incremental compilation]: profiles.md#incremental
1051 [profile]: profiles.md
1052 [program path with args]: #executable-paths-with-arguments
1053 [libcurl format]: https://ec.haxx.se/usingcurl-proxies.html
1054 [source replacement]: source-replacement.md
1055 [revision]: https://git-scm.com/docs/gitrevisions
1056 [registries]: registries.md
1057 [crates.io]: https://crates.io/