OUT_DIR is also set when running the program
Author: RalfJungCreated Sep 8, 2026Updated Sep 15, 2026
LabelsC-bugI-nominated-to-discussA-build-scriptsT-cargoA-environment-variablesfinal-comment-perioddisposition-mergeregression-from-stable-to-stable
The docs for OUT_DIR say (emphasis mine)
If the package has a build script, this is set to the folder where the build script should place its output. See below for more information. (Only set during compilation.)
However, in actuality, the environment variable is also set when the program is executed.
Either the docs should be adjusted to match the actual behavior, or the actual behavior should be adjusted to match the docs.
Source: rust-lang/cargo