Skip to content

Fall back to a real temporary directory when TMPDIR and TMP are unset - #521

Merged
fzhinkin merged 2 commits into
Kotlin:developfrom
lenamonj:tmpdir-fallback
Nov 4, 2026
Merged

fzhinkin merged 2 commits into
Kotlin:developfrom
lenamonj:tmpdir-fallback

Conversation

@lenamonj

@lenamonj lenamonj commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

On the Linux, Android Native and MinGW targets SystemTemporaryDirectory is Path("") when neither TMPDIR nor TMP is set, which is the normal state of a container, a systemd unit or a CI runner. Every path built from it then resolves against the filesystem root: with both variables unset, :kotlinx-io-core:linuxX64Test fails 19 tests with Failed to open /<name> with Permission denied, and SmokeFileTest.checkTmpDir fails on exists(SystemTemporaryDirectory).

The shared nativeNonApple actual is replaced by one per source set: unix falls back to /tmp, mingw falls back to GetTempPathA, which consults TMP, TEMP, USERPROFILE and the Windows directory in turn. Lookup order for a set variable is unchanged.

Verified on develop (5b94edd1): env -u TMPDIR -u TMP ./gradlew :kotlinx-io-core:linuxX64Test fails 19 of 1115 before, exits 0 after; compileKotlinMingwX64 and checkLegacyAbi pass. The MinGW change is compiled here, not run.

@fzhinkin
fzhinkin self-requested a review October 30, 2026 15:02
@fzhinkin fzhinkin self-assigned this Oct 30, 2026
@fzhinkin

Copy link
Copy Markdown
Collaborator

Sorry for the long time for the reply. In general, the change makes sense. I'll double check the behavior, update docs and will merge it everything is OK.

@fzhinkin

fzhinkin commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

I switched Windows version to using GetTempPathW, tweaked the buffer size and reduced the number of checked env variables to those not checked by the GetTempPathW.
On both Unix and Windows, blank env variables are ignored now.

@fzhinkin
fzhinkin merged commit ad6d923 into Kotlin:develop Nov 4, 2026
1 check passed
@lenamonj
lenamonj deleted the tmpdir-fallback branch November 4, 2026 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants