🐛 fix(unix): fall back to tempdir when runtime dir is not writable#369
Merged
gaborbernat merged 1 commit intotox-dev:mainfrom Feb 12, 2026
Merged
🐛 fix(unix): fall back to tempdir when runtime dir is not writable#369gaborbernat merged 1 commit intotox-dev:mainfrom
gaborbernat merged 1 commit intotox-dev:mainfrom
Conversation
gaborbernat
approved these changes
Aug 22, 2025
gaborbernat
requested changes
Aug 22, 2025
Member
gaborbernat
left a comment
There was a problem hiding this comment.
Looks good once you fix the CI.
6c4f908 to
569d313
Compare
95b3f61 to
752b28d
Compare
When XDG_RUNTIME_DIR is unset and the platform default runtime directory (e.g. /run/user/<uid>) does not exist or is not writable, fall back to a temporary directory via tempfile.gettempdir() instead of returning an unusable path. Closes tox-dev#368 Co-authored-by: Alex Lowe <alex.lowe@canonical.com>
752b28d to
d1f6c16
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
XDG_RUNTIME_DIRis unset and the platform default runtime directory (e.g./run/user/<uid>on Linux,/var/run/user/<uid>on BSD) does not exist or is not writable,user_runtime_dirpreviously returned the unusable path anyway. This caused failures for users in environments where the runtime directory hasn't been provisioned — containers, minimal installs, or systems wherelogindisn't managing the session. 🐛 See #368 for details.The fix checks writability via
os.accessinstead of mere existence, and falls back totempfile.gettempdir()when the default path isn't usable. This mirrors the existing BSD fallback pattern (which previously fell back to/tmp/runtime-<uid>) but now applies it uniformly across all Unix platforms and uses Python'stempfilemodule to respect platform-specific temp directory conventions.XDG_RUNTIME_DIRis unset,user_runtime_dirmay now return a different path than before on Linux systems where/run/user/<uid>doesn't exist. Previously it would return the non-existent/run/user/<uid>path; now it falls back to<tempdir>/runtime-<uid>. The$XDG_RUNTIME_DIRenvironment variable continues to take precedence when set.Closes #368
Co-authored-by: Alex Lowe alex.lowe@canonical.com