Skip to content

Use ~/Library/Caches for macOS runtime directory instead of $TMPDIR#8

Merged
Reidond merged 1 commit intomainfrom
claude/macos-stable-socket-path-adQYN
Mar 1, 2026
Merged

Use ~/Library/Caches for macOS runtime directory instead of $TMPDIR#8
Reidond merged 1 commit intomainfrom
claude/macos-stable-socket-path-adQYN

Conversation

@Reidond
Copy link
Owner

@Reidond Reidond commented Mar 1, 2026

Summary

Changes the macOS runtime directory for bwssh from $TMPDIR to ~/Library/Caches/bwssh, which is stable across reboots and aligns with macOS conventions.

Key Changes

  • src/bwssh/platform/_darwin.py: Updated get_runtime_dir() to return ~/Library/Caches/bwssh instead of using $TMPDIR or falling back to /tmp/bwssh-$UID. Added documentation explaining this is the macOS equivalent of Linux's $XDG_RUNTIME_DIR.
  • tests/test_platform.py: Updated test to verify the new behavior, removing the $TMPDIR environment variable mocking and asserting the path matches ~/Library/Caches/bwssh.
  • docs/content/1.getting-started/2.installation.md: Updated SSH_AUTH_SOCK export example to use the new path.
  • docs/content/2.cli/3.examples.md: Updated SSH_AUTH_SOCK export example for macOS to use the new path.
  • src/bwssh/data/config.toml.example: Updated configuration documentation to clarify platform-specific defaults.

Implementation Details

The previous implementation relied on $TMPDIR, which on macOS points to /var/folders/…/T/ and changes after each reboot. This caused issues with persistent socket paths. The new implementation uses ~/Library/Caches/, which is the standard macOS location for application cache data and remains stable across reboots, making it suitable for long-lived socket files.

https://claude.ai/code/session_01DcH3AgbT2qn854whDedajU

macOS $TMPDIR resolves to /var/folders/xx/<random>/T/ where the hash
changes after each reboot, making SSH_AUTH_SOCK in shell profiles
break. Switch to ~/Library/Caches/bwssh which is the macOS equivalent
of Linux's $XDG_RUNTIME_DIR — stable, per-user, and not backed up
by Time Machine.

https://claude.ai/code/session_01DcH3AgbT2qn854whDedajU
@Reidond Reidond merged commit 6d453d9 into main Mar 1, 2026
4 checks passed
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