question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

On Linux: respect XDG_CONFIG_HOME and don't store config in user's home directory

See original GitHub issue

The 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:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
alanmcruickshankcommented, Aug 7, 2020

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!

0reactions
NiallReescommented, Dec 6, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

XDG user directories - ArchWiki
This program reads a configuration file, and a set of default directories. It then creates localized versions of these directories in the users...
Read more >
Store settings and packages in XDG directories ... - GitHub
$XDG_CONFIG_HOME defines the base directory relative to which user specific configuration files should be stored. If $XDG_CONFIG_HOME is either ...
Read more >
What are the step to move all your dotfiles into XDG directories?
Second user-specific configuration file. If $XDG_CONFIG_HOME is not set or empty, $HOME/.config/git/config will be used. Any single-valued ...
Read more >
We lost control of our home directories : r/linux - Reddit
So, we have the standard XDG_CONFIG_HOME, which is ~/.config. ... Tell various programs to respect the XDG Base Directory specification ...
Read more >
XDG Base Directory Specification
$XDG_CONFIG_HOME defines the base directory relative to which user-specific configuration files should be stored. If $XDG_CONFIG_HOME is ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found