Description
The XDG_RUNTIME_DIR mapping in adrg/xdg does not align with established practices from other cross-platform libraries like platformdirs (Python) and dirs (Rust).
Currently, adrg/xdg sets:
- macOS →
~/Library/Application Support/
- Windows →
%LOCALAPPDATA%
However, there are two common approaches used in other libraries:
| OS |
platformdirs (Python) |
dirs (Rust) |
adrg/xdg (Current) |
| Linux |
/run/user/$UID |
/run/user/$UID |
✅ /run/user/$UID |
| macOS |
~/Library/Caches/TemporaryItems |
None |
❌ ~/Library/Application Support |
| Windows |
%TEMP% |
None |
❌ %LOCALAPPDATA% |
Two Common Approaches
platformdirs (Python): Fallbacks to a cache or temporary directory.
dirs (Rust): Returns None since XDG_RUNTIME_DIR is not officially defined for macOS and Windows.
As stated by dirs:
It is required that this directory is created when the user logs in, is only accessible by the user itself, is deleted when the user logs out, and supports all filesystem features of the operating system.
Possible Fixes
- Follow
platformdirs: Use
- macOS →
~/Library/Caches/TemporaryItems
- Windows →
%TEMP%
- Follow
dirs: Return nil for macOS/Windows.
Either would be better than the current behavior.
Description
The
XDG_RUNTIME_DIRmapping inadrg/xdgdoes not align with established practices from other cross-platform libraries likeplatformdirs(Python) anddirs(Rust).Currently,
adrg/xdgsets:~/Library/Application Support/%LOCALAPPDATA%However, there are two common approaches used in other libraries:
platformdirs(Python)dirs(Rust)adrg/xdg(Current)/run/user/$UID/run/user/$UID/run/user/$UID~/Library/Caches/TemporaryItemsNone~/Library/Application Support%TEMP%None%LOCALAPPDATA%Two Common Approaches
platformdirs(Python): Fallbacks to a cache or temporary directory.dirs(Rust): ReturnsNonesinceXDG_RUNTIME_DIRis not officially defined for macOS and Windows.As stated by
dirs:Possible Fixes
platformdirs: Use~/Library/Caches/TemporaryItems%TEMP%dirs: Returnnilfor macOS/Windows.Either would be better than the current behavior.