From 1607a68e92659a687892a49a463d06e3576b057f Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Tue, 2 Feb 2021 18:07:12 -0800 Subject: [PATCH] Add note about `cargo:rustc-env` variables set at runtime. --- src/doc/src/reference/build-scripts.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/doc/src/reference/build-scripts.md b/src/doc/src/reference/build-scripts.md index 6e4083a7a3c..7d5805ba703 100644 --- a/src/doc/src/reference/build-scripts.md +++ b/src/doc/src/reference/build-scripts.md @@ -192,6 +192,12 @@ unique identifier of a continuous integration server. See also the [environment variables automatically included by Cargo][env-cargo]. +> **Note**: These environment variables are also set when running an +> executable with `cargo run` or `cargo test`. However, this usage is +> discouraged since it ties the executable to Cargo's execution environment. +> Normally, these environment variables should only be checked at compile-time +> with the `env!` macro. + [env-macro]: ../../std/macro.env.html [env-cargo]: environment-variables.md#environment-variables-cargo-sets-for-crates