ludic/changes/os-known-folders.md
Orkuncakilkaya 6bcb5f4ae1 fix(os): save_dir/config_dir/cache_dir follow the platform, not just macOS
They were the macOS layout on every platform - the comment above them even said
"macOS/BSD layout" - so a game built on Linux wrote its saves to
~/Library/Application Support, a directory that means nothing there. Naming the
right directory is the entire reason a program calls these instead of joining a
path itself.

  macOS   save/config  ~/Library/Application Support/<app>
          cache        ~/Library/Caches/<app>
  Linux   save         $XDG_DATA_HOME   or ~/.local/share/<app>
          config       $XDG_CONFIG_HOME or ~/.config/<app>
          cache        $XDG_CACHE_HOME  or ~/.cache/<app>

macOS is unchanged to the byte, deliberately. save_dir and config_dir stay the
same directory there: Apple's home for a config file that is not an
NSUserDefaults plist is Application Support too, and a shipped game's settings
must not move out from under it. On Linux XDG separates the two and so does this.
An XDG variable that is set but EMPTY falls back to the default, which is what
the spec says and what an exported-but-unset variable looks like from a shell.

uname is read once and remembered rather than per call, because save_dir is
called on every save.

Verified on both branches. macOS by running it; the Linux branch by building the
probe's IR with the cached platform flag pinned, which exercises the emitted XDG
code exactly - unset, set, and set-but-empty all resolve as the spec says. The
suite's own case asserts the HOST's convention, so a macOS box covers the Apple
branch and CI covers XDG.

This is a backend change, so selfhost/ludicc.seed.ll is reseeded with it: the
bootstrap fixpoint (gen2 == gen3) and the C-free rebuild from the seed both pass.
2026-09-11 19:46:47 +03:00

1.4 KiB

bump: patch type: fix Os.save_dir / Os.config_dir / Os.cache_dir follow the platform. They were the macOS layout everywhere, so a game built on Linux wrote its saves to ~/Library/Application Support — a directory that means nothing there. Naming the right directory is the entire reason a program calls these instead of building a path.

macOS Linux
save_dir ~/Library/Application Support/<app> $XDG_DATA_HOME or ~/.local/share/<app>
config_dir ~/Library/Application Support/<app> $XDG_CONFIG_HOME or ~/.config/<app>
cache_dir ~/Library/Caches/<app> $XDG_CACHE_HOME or ~/.cache/<app>

An XDG variable that is set but empty falls back to the default, as the spec requires. macOS is unchanged to the byte — save_dir and config_dir stay the same directory there, because Apple's home for a config file that is not an NSUserDefaults plist is Application Support too, and a shipped game's settings must not move out from under it. On Linux XDG separates the two and so does this.

One consequence worth stating plainly: a game already shipped on Linux was writing to the old macOS-shaped path, and this moves it. Those files are not migrated for you — they are wherever ~/Library/Application Support/<app> ended up on that machine, and a game that has Linux players should move them once on startup.