Remark TMP
, TEMP
and USERPROFILE
env vars can influence env::temp_dir
on Windows
#125439
Labels
A-docs
Area: Documentation for any part of the project, including the compiler, standard library, and tools
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
O-windows
Operating system: Windows
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
Location
std::env::temp_dir
std::process::Command::env_clear
Summary
Encountered in #122580 (comment).
In codegen we (transitively) use
env::temp_dir()
for some temporary files. If you unset (or provide a value that is not a writable directory) all threeTMP
,TEMP
,USERPROFILE
env vars (such as by callingCommand::env_clear
on some cargo invocation) on Windows, thenenv::temp_dir()
can return the Windows directory which is often not writable.This is documented in
GetTempPath2W
, but it might be worth a remark on the docs forenv::temp_dir
andCommand::env_clear
that modifying or unsettingTMP
,TEMP
andUSERPROFILE
can influence the result ofenv::temp_dir
on Windows.It is already pointed out that
env::temp_dir
returns value ofTMPDIR
on Linux.The text was updated successfully, but these errors were encountered: