-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Remark TMP, TEMP and USERPROFILE env vars can influence env::temp_dir on Windows #125439
Copy link
Copy link
Closed
Closed
Copy link
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.O-windowsOperating system: WindowsOperating system: WindowsT-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.O-windowsOperating system: WindowsOperating system: WindowsT-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Location
std::env::temp_dirstd::process::Command::env_clearSummary
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,USERPROFILEenv vars (such as by callingCommand::env_clearon 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_dirandCommand::env_clearthat modifying or unsettingTMP,TEMPandUSERPROFILEcan influence the result ofenv::temp_diron Windows.It is already pointed out that
env::temp_dirreturns value ofTMPDIRon Linux.