rc9 icon indicating copy to clipboard operation
rc9 copied to clipboard

Fallback to `$HOME/.config` if `$XDG_CONFIG_HOME` is not set

Open ap-1 opened this issue 1 year ago • 5 comments

Just a minor nitpick--as someone with an extremely cluttered /home/{name} directory from all of the config files creates by various applications, I think it would be a better idea to recommend the use of /home/{name}/.config here.

I'm not sure about the convention for MacOS and Windows, but hopefully they also have a standard location for applications to create config files.

https://github.com/unjs/rc9/blob/b9ab9e9c79873956525a97ac4202280f90824187/README.md?plain=1#L69-L79

ap-1 avatar Nov 02 '23 23:11 ap-1

Thanks for making issue. Honestly i tend to agree with you. It is always easier to find relevant config files from ~/.config (also cache from ~/.cache etc).

Main tricky part is how we can make a change without breaking changes i guess or reduce the surface as rc9 is used internally in other projects such as c12 > nitro > nuxt, etc.

pi0 avatar Nov 03 '23 10:11 pi0

I'm not very acquainted with the codebase, but at first glance it seems like readUser, writeUser, and updateUser can be deprecated in favor of new readConfig, writeConfig, and updateConfig methods. These would rely on $XDG_CONFIG_HOME rather than $HOME.

Whether to fall back to $HOME if $XDG_CONFIG_HOME doesn't exist or to create $XDG_CONFIG_HOME properly based on the OS is another question.

ap-1 avatar Nov 03 '23 20:11 ap-1

Nice idea to introduce new utils, we could call them *userConfig()

pi0 avatar Nov 06 '23 11:11 pi0

I know Vercel CLI is using https://www.npmjs.com/package/xdg-app-paths for example to get the path

atinux avatar Feb 17 '24 18:02 atinux

The git CLI calls the different locations global (~/.gitconfig and ~/.config/git/config), system (config under /etc) and local (config from the current directory). For global it simply reads both files which would be backwards compatible and writes to the latter location if it already exists and the former otherwise.

septatrix avatar Mar 03 '24 16:03 septatrix