Skip to content

Commit 4d7a29b

Browse files
committed
Document the configurable-env usntable option
1 parent f7a7a3f commit 4d7a29b

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/doc/src/reference/unstable.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,3 +1130,29 @@ The 2021 edition will set the default [resolver version] to "2".
11301130
The `-Z future-incompat-report` flag enables the creation of a future-incompat report
11311131
for all dependencies. This makes users aware if any of their crate's dependencies
11321132
might stop compiling with a future version of Rust.
1133+
1134+
### configurable-env
1135+
* Original Pull Request: [#9175](https://github.com/rust-lang/cargo/pull/9175)
1136+
1137+
The `-Z configurable-env` flag enables the `[env]` section in the
1138+
`.cargo/config.toml` file. This section allows you to set additional environment
1139+
variables for build scripts, rustc invocations, `cargo run` and `cargo build`.
1140+
1141+
```toml
1142+
[env]
1143+
OPENSSL_DIR = "/opt/openssl"
1144+
```
1145+
1146+
By default, the variables specified will not override values that already exist
1147+
in the environment. This behavior can be changed by setting the `force` flag.
1148+
1149+
Setting the `relative` flag evaluates the value as a config-relative path that
1150+
is relative to the parent directory of the `.cargo` directory that contains the
1151+
`config.toml` file. The value of the environment variable will be the full
1152+
absolute path.
1153+
1154+
```toml
1155+
[env]
1156+
TMPDIR = { value = "/home/tmp", force = true }
1157+
OPENSSL_DIR = { value = "vendor/openssl", relative = true }
1158+
```

0 commit comments

Comments
 (0)