ruff icon indicating copy to clipboard operation
ruff copied to clipboard

Global Config Discovery: use `$XDG_CONFIG_HOME` on macOS

Open SPiCaRiA opened this issue 1 year ago • 9 comments

Hi, I'm newly migrating to ruff and it works so far so good for me, thank you for making this great tool!

However, I noticed that ruff uses the config_dir in dirs crates, which goes to $HOME/Library/Application Support under macOS. Generally I believe that as a CLI tool (and like many others), ruff should probably stick with XDG config home under macOS. When I look into my $HOME/Library/Application Support, they're almost all GUI application stuffs. Also, I think it is expected & intuitional to read config from $XDG_CONFIG_HOME since macOS mostly behave in *nix way.

Please let me know what you think :)

SPiCaRiA avatar Apr 02 '24 14:04 SPiCaRiA

This seems reasonable to me but I'd like to hear from someone else on our team first too.

zanieb avatar Apr 02 '24 14:04 zanieb

We have a similar request in a comment for uv as well: https://github.com/astral-sh/uv/issues/1511

I'm not a macOS user so I don't have a good sense of what the right choice is. But my understanding is that XDG_CONFIG_HOME is commonly used on macOS. I have a fair number of things in my ~/.config directory on my test mac mini for example.

BurntSushi avatar Apr 02 '24 14:04 BurntSushi

I prefer Linux to macOS but use macOS as a daily driver and I would be very confused if ~/.config was not a valid configuration path.

zanieb avatar Apr 02 '24 14:04 zanieb

I use macOS exclusively. Honestly, I wouldn't know where to expect the config to go. I'd have to look it up in the docs for any given tool. But looking at my machine, I do think ~/.config is more appropriate.

charliermarsh avatar Apr 02 '24 16:04 charliermarsh

That was a matter of discussion for PDM too (which does not recognise the XDG_* vars for macOS). PDM does this because the underlying Python package platformdirs does this. As a mac user who versions their dotfiles, I spent a bit of time to make sure that as many projects as I use can save data under ~/.config. It makes the most sense, it's more portable.

baggiponte avatar Apr 04 '24 21:04 baggiponte

Could you report this upstream at https://github.com/dirs-dev/dirs-rs? I'm not a mac user so i'm not qualified to weigh in on this, i just wouldn't want to diverge from the effective rust standard without an upstream discussion first

konstin avatar Apr 17 '24 09:04 konstin

@konstin I think it's been discussed before upstream and they are pretty opposed: https://github.com/dirs-dev/directories-rs/issues/47

I don't think I'd consider dirs-rs to be an effective Rust standard personally. But it is probably the most popular implementation of XDG.

There's also some other discussion that touches on this topic here: https://internals.rust-lang.org/t/pre-rfc-split-cargo-home/19747

BurntSushi avatar Apr 17 '24 11:04 BurntSushi

And in particular, it looks like dirs won't respect XDG_CONFIG_HOME on macOS? https://github.com/dirs-dev/directories-rs/issues/47#issuecomment-596467168

BurntSushi avatar Apr 17 '24 12:04 BurntSushi

If we want xdg over the platform default on mac, we should consider switching to something like etcetera's Xdg and etcetera::app_strategy::choose_app_strategy ("Returns the current OS’s default AppStrategy This uses the Windows strategy on Windows, and Xdg everywhere else.") over directories.

konstin avatar Apr 17 '24 12:04 konstin