Respect XDG_CONFIG_HOME in _get_user_dirs_folder#453
Merged
gaborbernat merged 3 commits intotox-dev:mainfrom Feb 23, 2026
Merged
Respect XDG_CONFIG_HOME in _get_user_dirs_folder#453gaborbernat merged 3 commits intotox-dev:mainfrom
gaborbernat merged 3 commits intotox-dev:mainfrom
Conversation
The _get_user_dirs_folder function hardcodes ~/.config as the location for user-dirs.dirs, ignoring XDG_CONFIG_HOME. According to the XDG Base Directory Specification, XDG_CONFIG_HOME should be checked first, falling back to ~/.config only when unset or empty. This is particularly relevant for users who have a custom XDG_CONFIG_HOME set, as the function would read the wrong user-dirs.dirs file (or fail to find it).
Verify that user-dirs.dirs is read from a custom XDG_CONFIG_HOME directory instead of always using ~/.config.
Contributor
Author
|
Added a test that sets |
for more information, see https://pre-commit.ci
gaborbernat
approved these changes
Feb 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_get_user_dirs_folderhardcodes~/.configas the location for reading theuser-dirs.dirsconfiguration file, ignoring theXDG_CONFIG_HOMEenvironment variable.Problem
The XDG Base Directory Specification defines
$XDG_CONFIG_HOMEas the base directory for user-specific configuration files, defaulting to$HOME/.configonly when unset or empty. The_get_user_dirs_folderfunction always reads from~/.config/user-dirs.dirs, so users who have set a customXDG_CONFIG_HOMEwill have the wrong config file read (or the file won't be found at all).This is especially inconsistent since the rest of the Unix implementation correctly respects
XDG_CONFIG_HOMEforuser_config_dir.Fix
Read
XDG_CONFIG_HOMEfrom the environment first, falling back to~/.configwhen unset or empty: