Skip to content

Fix issue #48093: set SystemTemp environment variable#52181

Open
chemodax wants to merge 1 commit intomoby:masterfrom
chemodax:patch-1
Open

Fix issue #48093: set SystemTemp environment variable#52181
chemodax wants to merge 1 commit intomoby:masterfrom
chemodax:patch-1

Conversation

@chemodax
Copy link
Contributor

@chemodax chemodax commented Mar 16, 2026

On Windows also set the SystemTemp environment variable, because for system processes GetTempPath2() uses it rather than TEMP/TMP: https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppath2w

- Windows: Fix `DOCKER_TMPDIR` not being respected

Copy link
Contributor

@vvoland vvoland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Change looks good to me, but:

  1. Please squash into one commit
  2. Please use your real name in a sign-off (currently is Signed-off-by: chemodax)

On Windows also set the SystemTemp environment variable, because for system processes GetTempPath2() uses it rather than TEMP/TMP:
https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppath2w

Signed-off-by: Ivan Zhakov <ivan@chemodax.net>
@chemodax
Copy link
Contributor Author

Thanks! Change looks good to me, but:

1. Please squash into one commit

2. Please use your real name in a sign-off (currently is `Signed-off-by: chemodax`)

It should be fixed now. Thanks!

@vvoland vvoland added the kind/bugfix PR's that fix bugs label Mar 17, 2026
@vvoland vvoland added this to the 29.3.1 milestone Mar 17, 2026
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@vvoland PTAL

Comment on lines 864 to +869
_ = os.Setenv("TEMP", realTmp)
_ = os.Setenv("TMP", realTmp)
// Set the SystemTemp environment variable, because for system processes
// GetTempPath2() uses it rather than TEMP/TMP:
// https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppath2w
_ = os.Setenv("SystemTemp", realTmp)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a quick check if we had any code depending on the env-var specific, but only in a test-utility, and that one already had a comment to suggest using os.Tempdir() instead;

git grep -E 'os.Getenv\("(TMP|TEMP|TMPDIR)"\)'
integration-cli/utils_test.go:          tmp = os.Getenv("TEMP")

git grep -E 'os.LookupEnv\("(TMP|TEMP|TMPDIR)"\)'
# no results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants