Skip to content

Support XDG directories on macOS #117

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

Open
strega-nil opened this issue May 15, 2025 · 4 comments · May be fixed by #119
Open

Support XDG directories on macOS #117

strega-nil opened this issue May 15, 2025 · 4 comments · May be fixed by #119

Comments

@strega-nil
Copy link

Hiya!

I've been going around different Rust apps that I use, and trying to fix this issue, and I noticed that this crate was reasonably official, and still broken.

The directories used right now are great for GUI apps (i.e., applications that live in /Applications), but is extremely unexpected for unix/CLI style applications. It seems really unfortunate to break people's expectations like this, especially because most people just end up using confy without thinking through the implications of a very odd configuration location.

We have a few examples of applications that used to do it the dirs way, because they just did "the default" thing, and then they've had to change to be correct:

And some examples of applications that have always used XDG on macOS (or which switched from a dotfile in the home directory to XDG when XDG became a standard), including both Rust applications and applications that are from outside the Rust ecosystem:

  • git
  • neovim
  • gcloud
  • iterm2 uses both
  • kitty
  • tmux
  • wezterm
  • dust
  • fd

Additionally, it looks like cargo will be switching to using XDG directories Soon (tm) - thread here

I will also point out that I don't think any macOS developers have ever complained about programs putting their configuration files in ~/.config – but quite a few have complained about configuration being in ~/Library/Application Support. I made the change for jj, and I have had like five people message me thanking me for fixing it. It is not expected for CLI application to put their configuration in ~/Library, and I would appreciate if the semi-official Rust stuff supported the correct paths.

Of course, for GUI applications, it may be the case that you want your configuration in ~/Library/Application Support – that means you'll likely want to still be able to put configuration there, but the default should almost certainly be in ~/.config, since the application that's likely to use confy is likely to be a CLI app.

@Zykino
Copy link
Contributor

Zykino commented May 15, 2025

I don’t understand, we are using dirs exactly so they can have sane defaults that we can rely on them for. To me dirs should use the XDG env var if they exist, or a correct default, maybe with a config "graphic or command line".

Do they have a reason stated why they don’t do it that way?

@strega-nil
Copy link
Author

strega-nil commented May 15, 2025

@Zykino yes, they don't do it that way because they read the standard incorrectly, and are extremely stubborn that XDG directories do not belong on macOS. dirs is, unfortunately, both opinionated and wrong. Here are the links to the issue threads:

The correct behavior has been implemented in etcetera

@deg4uss3r
Copy link
Contributor

I have a local draft for this that I am finishing up. It's step 1 which puts xdg behind a feature flag so you can use it now.

@deg4uss3r deg4uss3r linked a pull request May 25, 2025 that will close this issue
@deg4uss3r
Copy link
Contributor

I've opened #119

If one could test on linux to make sure this doesn't break between versions I'd be very appreciative, I'd like to ensure we don't regress anyone currently using a binary built on top of this without knowing it (I do plan on a 1.1 release) but would like to know what changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants