-
Notifications
You must be signed in to change notification settings - Fork 632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use platform-specific cache paths and respect XDG_CACHE_HOME
#3458
Use platform-specific cache paths and respect XDG_CACHE_HOME
#3458
Conversation
$HOME/Library/Caches
on macOS instead of $HOME/.cache
XDG_CACHE_HOME
2755df7
to
074ff33
Compare
074ff33
to
3b5bc77
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is generally a good change and addresses a blocker for some people on macOS, so I'm motivated to see a solution get merged. Thanks for working on this!
There are some follow-ups that I think are interesting to think about afterward, but I don't think any of them are blocking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really able to review the changes as I don't know the codebase. As long ghostty starts with read-only home directory and uses platform directories, it's enough for me atm. Parity with Application Support, bundle id wise, would be nice but not a show stopper.
3b5bc77
to
99e8604
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think xdg.cache
should return anything but the XDG cache dir as specified.
I think the calling point for xdg.cache
should be modified to call this for macOS instead.
99e8604
to
39a0ef3
Compare
39a0ef3
to
10bbc26
Compare
c7dcf2a
to
73eb21a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks good. I noted one issue/question.
73eb21a
to
a605c74
Compare
a605c74
to
6fca269
Compare
Description:
Use proper platform-specific methods to determine cache directory paths:
First check
XDG_CACHE_HOME
environment variableOn macOS:
Use
NSFileManager.URLForDirectory
to get system cache path (~/Library/Caches
)Use bundle ID (
com.mitchellh.ghostty
) as base directory to follow macOS conventionsFall back to XDG spec defaults for other platforms (
~/.cache
)Changes:
Extract common NSFileManager path lookup logic into
makeCommonPath
helperUse
NSFileManager.URLForDirectory
to get proper macOS cache directoryUse bundle ID for macOS cache directory to match system conventions and
appSupportDir
behaviorFollows the same pattern as our configuration file path (
~/Library/Application Support/com.mitchellh.ghostty/config
)Aligns with
appSupportDir
implementation which already uses bundle IDAdd tests to verify path construction for different platforms
Questions for reviewers:
Should we add migration logic for existing cache files?
Or should we document this as a breaking change and let users manually clean up?
Testing:
Added unit tests for path construction:
macOS: verifies
~/Library/Caches/com.mitchellh.ghostty
pathLinux: verifies
~/.cache/ghostty
path (XDG spec)Verified tests pass with
zig build test
Fixes #3202