macOS dotfiles should not go in ~/Library/Application Support

53 points by hibachrach


mitchellh

This is missing a messy point in favor of AppSupport: its hard to support changing XDG_CONFIG_HOME. macOS has no concept of a “login shell”, so you can’t override XDG env vars within your login scripts like ~/.zprofile for apps that aren’t launched via a shell (including shell scripts launched directly via shebang, not in an interactive shell env, which is the major gotcha here).

For CLI apps this isn’t an issue since you’re executing them from a terminal context which likely loaded a non-login interactive profile script (~/.zshrc). And any child processes are inheriting that environment. But due to historical… mistakes… all terminals on macOS also load login scripts for all non-login terminals too. Read this for some history on how messed up this is (no other platform behaves this way!): https://ghostty.org/docs/help/macos-login-shells

For GUI apps, this is an issue because GUI apps are launched via PID 1 which has not loaded any login scripts and has a bare environment. So you have to use launchd to manage the env vars: https://stackoverflow.com/a/588442

I build a terminal, which is kind of a hybrid GUI/CLI app: we have a GUI obviously, but lots of people also launch terminals via the CLI. And users of terminals tend to be highly technical so they’re more aware of XDG and want to use it. But they’re also so technical they often MOVE their XDG folders for reasons. But also a lot of people don’t care about this and I’ve found that “normie” macOS technical users do expect configs in ~/Library. This is the perfect storm of nightmare. So we support both. Yay! (gouches eyes)

None of the above is hypothetical, we’ve had dozens of bug reports or Q&A posts on this topic on all sides…

I don’t think any of this refutes this post. I think its all very messy. But this is a point that I haven’t found documented anywhere and I discovered organically through my own app and it is common enough that I felt the need to share this and hopefully get it indexed or something.