Skip to content

Incorrect Mapping of XDG_RUNTIME_DIR on macOS and Windows #120

@gaesa

Description

@gaesa

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

  1. Follow platformdirs: Use
    • macOS~/Library/Caches/TemporaryItems
    • Windows%TEMP%
  2. Follow dirs: Return nil for macOS/Windows.

Either would be better than the current behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions