Live data from Hacker News

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

becca.ooo

101–110 of 223 posts

Re: macOS dotfiles should not go in –/Library/Application Support

#101
As a decades long time Mac user, when I see something show up in ~/.config it just feels like a maladapted port. It's a similar feel to seeing .dotfiles that are not actually hidden on Windows. Like, whelp, they didn't even bother.

No part of macOS's desktop uses or specifies the XDG standard, it's not a POSIX standard nor a standard embraced by the OS. Following it is applying someone else's custom.

As another commenter mentioned though, ~/Library/Preferences is likely the more correct location on macOS.

Re: macOS dotfiles should not go in –/Library/Application Support

#102
None of the tools the author mentions as following XDG, actually follow XDG. No default tools shipped with macOS place files under .config or anything like that. There is a bunch of dotfile vomit in $HOME and that's it. Every tool that uses .config is one you manually install from an external source.

The XDG spec is to coordinate the userspace of Linux software, meaning both CLI apps and windowed apps. Linux needs things called standards because Linus has not bothered to write them down himself, so there is no equivalent of Microsoft telling you data goes in AppData and Apple telling you data goes in Library. Identifying it as a standard for CLI tools across OSes is just wrong.

When CLI tools do this on macOS, it is not because anyone thought 'this is a standard for macOS', it is because they thought 'with -target darwin I don't get any compilation errors. ship it!' and frequently use those locations on Windows too where they don't make any kind of sense at all.

The standardized location is Library. If you do not expect it, that is on you; you should expect it, as it is the standardized location. It is only just now that people are starting to catch up with it, instead of blind ports with absolute minimum macOS-specific code, because of libraries like `dirs` which make it easy.

Re: macOS dotfiles should not go in –/Library/Application Support

#103
post #29

If your binary is supposed to live in `/Applications`, by all means put its config in `~/Application Support`. If it lives in `/bin` or somewhere similar, or if its default or system-wide configuration go in `/etc`, config goes in `~/.config`.

I prefer https://uapi-group.org/specifications/specs/configuration_fi...

Defaults should go in /usr/. It is package developer / maintainer territory.

System-wide overrides should go in /etc/. It is the purview of the system administrator. Importantly:

> Programs must work correctly if no configuration files are found in /etc/.

User-specific overrides should go in XDG_CONFIG_HOME, with a fallback to ~/.config/.

Re: macOS dotfiles should not go in –/Library/Application Support

#104
post #3

I and others have brought this up with the dirs Rust crate maintainer but they refuse to see it this way: https://codeberg.org/dirs/dirs-rs/issues/64 . It's very frustrating. I now use a combination of xdg + known-folders manually: [target.'cfg(windows)'.dependencies] known-folders = "1.2.0" [target.'cfg(not(windows))'.dependencies] xdg = "2.5.2" to get the config directory: use anyhow::{Context, Result}; #[cfg(windo…

> they refuse to see it this way That's why the long-term future of app development is containers. It is not possible, on a human level, to convince people to lift even the lightest of fingers for the common good. Consider https://specifications.freedesktop.org/basedir-spec/latest/ The XDG specification has been around for 22 years. It has real benefits for users. It's trivial to implement. Yet even in the year of ou…

> The XDG specification has been around for 22 years.

Indeed!

> It has real benefits for users.

I once believed this!

> It's trivial to implement.

Nope!

I ranted about this a while back (https://bsky.app/profile/str4d.xyz/post/3lsjbnpsbh22i) but the tl;dr is that the XDG specification is imprecisely written and internally inconsistent, and there has been confusion since at least as early as 2003 about what kind of data is meant to be stored in $XDG_CONFIG_HOME vs $XDG_DATA_HOME.

A plain reading of the XDG Base Directory Specification implies (but does not explicitly say, which is part of the problem!) that $XDG_DATA_HOME contains read-only user-specific application data files (like documentation).

But the spec is interpreted by many (source: I found a single blog post that seemed to be referenced in a variety of places, such as the Arch Linux wiki) as saying that $XDG_DATA_HOME contains mutable user-generated data (like password vaults).

Those have very different properties, and it's impossible as an app developer for me to predict which of those two directories a user (or the tooling installed on their OS) is assuming can be safely deleted without consequence, and which must always be backed up.

> Yet even in the year of our lord two thousand and twenty five I still see TypeScript developers complain that it's "too hard" to comply with "this BS" and just stick files in $HOME.

My earlier rant arose from me spending several days attempting to follow the XDG specification for an app where I need to store mutable user-generated data, being unable to find any supporting evidence that it was safe to store this in either $XDG_CONFIG_HOME or $XDG_DATA_HOME, and deciding on ~/.appname instead. I do allow all paths to be overridden in the config file, so individual users can use XDG paths at their own risk (and with knowledge of their OS environment's behaviour).

Re: macOS dotfiles should not go in –/Library/Application Support

#105

The hint is in the name. "Application Support" has a space in it, so it's not designed to be used for CLI config.

Are there still CLI tools that can't handle spaces in folder names?

It's annoying and not ergonomic.

Re: macOS dotfiles should not go in –/Library/Application Support

#106

I put them in a dotfiles directory and use `stow`[1] to symlink the contents to where applications expect them to be. Under that root I have a home folder that it is symlinked to `~/`, and I have and applications one that is symlinked to `Applications Support` through the `-T` argument of stow. To this day I still have to find anything that has problems taking a symlink instead of a file. I am pretty happy with this…

I also use stow on MacOS and have been pretty happy with it. > […]although macOS will regularly replace your symlinks with copies of the destination files I’m curious about this claim from the article - to what extent is this true?

https://github.com/lra/mackup?tab=readme-ov-file#warning

Perhaps referencing this behaviour where preference files can no longer be symlinks?

> Mackup does not work correctly in macOS Sonoma and all later versions, since it does not support symlinked files for preferences.

Re: macOS dotfiles should not go in –/Library/Application Support

#107

None of the tools the author mentions as following XDG, actually follow XDG. No default tools shipped with macOS place files under .config or anything like that. There is a bunch of dotfile vomit in $HOME and that's it. Every tool that uses .config is one you manually install from an external source. The XDG spec is to coordinate the userspace of Linux software , meaning both CLI apps and windowed apps. Linux needs t…

What, there are other OSes that are not Linux? But why would you use them, just use Linux instead? Okay, fine, we'll pretend they're kinda Linux anyway and build the binaries for you. "Wrong paths"? Okay, patch it yourself then or something, idgaf about your weird non-Linux.

...seems to be a rather popular attitude between mainly-Linux based developers. I get it that it's easier to just read/write from/to "C:\etc\ssh\ssh_config" or "%HOME%\.dotfiles_are_cool_do_you_think_dotfiles_are_cool_no_I_will_not_set_hidden_attribute_on_it_why_would_I" but sometimes it's a bit jarring. Especially when the app doesn't work when placed inside a "Program Files" folder because it has spaces in the path.

Re: macOS dotfiles should not go in –/Library/Application Support

#108

Earlier quoted context omitted.

Where did OP said that "XDG_CONFIG_DIR is always ~/.config"? You can of course set it to another directory, if you wish so, and that should be respected.

So set it to ~/Library/Preferences and no one should be complaining - Apple see configs in the correct place and XDG see it correct as well. So why is there a problem?

Apple's docs have this to say about ~/Library/Preferences/:

This directory contains app-specific preference files. You should not create files in this directory yourself.

Re: macOS dotfiles should not go in –/Library/Application Support

#109

None of the tools the author mentions as following XDG, actually follow XDG. No default tools shipped with macOS place files under .config or anything like that. There is a bunch of dotfile vomit in $HOME and that's it. Every tool that uses .config is one you manually install from an external source. The XDG spec is to coordinate the userspace of Linux software , meaning both CLI apps and windowed apps. Linux needs t…

> The standardized location is Library.

Except for Zsh (~/.zshrc), SSH (~/.ssh/config), Vim (~/.vimrc), Curl (~/.curlrc), Git (~/.gitconfig). Apple could have chosen to patch these and move the configuration files into ~/Library if they really wanted.

Post reply on HN