On Linux: respect XDG_CONFIG_HOME and don't store config in user's home directory
See original GitHub issueThe XDG Base Directory standard states that user config files should respect the XDG_CONFIG_HOME
environment variable, which defaults $HOME/.config
.
Currently, sqlfluff looks for a user’s global config file in ~/.sqlfluff
. I, like many heavy terminal users, have a lot of files in our home directories, and prefer to use the ~/.config
directory whenever possible.
The .config
dir is only relevant to Linux users. On OSX, the standard says config files should live in ~/Library/Application Support/<AppName>
. On Windows the standard is C:\Documents and Settings\<User>\Application Data\Local Settings\<AppAuthor>\<AppName>
. The appdirs
pypi package makes all three of these standards simple to implement. And I suggest providing a fallback to ~/.sqlfluff
should there not be an OS specific sqlfluff config file present.
If you agree with this issue, I’d be happy to implement it!
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Hi @sethwoodworth - I wasn’t aware of that package - looks great!
Yes if you’re happy to implement, I’d be very happy to receive a PR on this.
We probably have some existing users who want to keep their config in
~/.sqlfluff
, so I’d love to keep that as an option. You’ll see in that the logic for the config files means that they layer on top of each other, so the ordering matters, and I think for config files in the locations that you mention that they should come before any files found at~/.sqlfluff
.In other words, if you look at the docs here: https://docs.sqlfluff.com/en/latest/configuration.html#nesting, I think that the config files in the locations you mention should come between step 0 and step 1.
Finally if you could update the docs page that I’ve linked above in the same PR describing what you’ve done, that would be excellent. I’m looking forward to this one!
Let’s close for now as the initial issue is resolved. If there’s a need for a new issue let’s do that though.