Skip to content

get_runtime_dir: only ask platformdirs if needed (fixes Haiku CI) - #10646

Merged
ThomasWaldmann merged 1 commit into
borgbackup:masterfrom
ThomasWaldmann:fix-haiku-runtime-dir
Nov 24, 2026
Merged

ThomasWaldmann merged 1 commit into
borgbackup:masterfrom
ThomasWaldmann:fix-haiku-runtime-dir

Conversation

@ThomasWaldmann

Copy link
Copy Markdown
Member

Description

Fixes the 2 test failures of the Haiku CI job (test_get_runtime_dir, test_get_dir_subdirs in helpers/fs_test.py), which fails on master and on all PRs since platformdirs 4.14.8 got released:

PermissionError: runtime directory /tmp/runtime-0 is below /boot/system/cache/tmp, writable by another user; set XDG_RUNTIME_DIR instead

platformdirs 4.14.8 raises PermissionError if it does not find a safe runtime directory (tox-dev/platformdirs#744). That is the case on Haiku: there is no /run/user and /tmp is writable by all users without having the sticky bit set.

Changes:

  • get_runtime_dir: only ask platformdirs if neither BORG_RUNTIME_DIR nor BORG_BASE_DIR is set. Before, the platformdirs default was computed (as the default argument of os.environ.get) even if BORG_RUNTIME_DIR was set, so the function failed on Haiku no matter what.
  • test_get_runtime_dir: do not check the platformdirs-derived runtime directory (default and XDG_RUNTIME_DIR) on Haiku, only the BORG_RUNTIME_DIR override.
  • new test_get_runtime_dir_without_platformdirs: BORG_RUNTIME_DIR / BORG_BASE_DIR work even if platformdirs.user_runtime_dir raises (runs on all platforms, fails without the fs.py change).

Notes for the reviewer:

  • get_runtime_dir has no callers outside of the test suite, so this did not affect borg users.
  • On Haiku, get_runtime_dir() still raises PermissionError if neither env var is set; this PR does not add a fallback for that.
  • Tested on macOS with platformdirs 4.13.5 and 4.14.8. Not tested on Haiku locally, the Haiku CI job of this PR is the first run there.

Checklist

  • PR is against master (or maintenance branch if only applicable there)
  • New code has tests and docs where appropriate
  • Tests pass (run tox or the relevant test subset)
  • Commit messages are clean and reference related issues

🤖 Generated with Claude Code

platformdirs 4.14.8 raises PermissionError if it does not find a safe
runtime directory. That is the case on Haiku: there is no /run/user and
/tmp is writable by all users without having the sticky bit set.

get_runtime_dir computed the platformdirs default even if BORG_RUNTIME_DIR
was set, so it failed on Haiku no matter what. Now it only asks platformdirs
if neither BORG_RUNTIME_DIR nor BORG_BASE_DIR is set.

tests: do not check the platformdirs runtime directory on Haiku, add a
test for BORG_RUNTIME_DIR / BORG_BASE_DIR working without platformdirs.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.44%. Comparing base (0b58a28) to head (7453b34).
⚠️ Report is 13 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10646      +/-   ##
==========================================
- Coverage   89.45%   89.44%   -0.01%     
==========================================
  Files         105      105              
  Lines       20341    20343       +2     
  Branches     3199     3200       +1     
==========================================
  Hits        18196    18196              
- Misses       1491     1492       +1     
- Partials      654      655       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@ThomasWaldmann
ThomasWaldmann merged commit 7711fdb into borgbackup:master Nov 24, 2026
24 of 25 checks passed
@ThomasWaldmann
ThomasWaldmann deleted the fix-haiku-runtime-dir branch November 24, 2026 14:07
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.

1 participant