Skip to content

Prefer explicit XDG_CONFIG_HOME during configuration discovery - #217

Open
Imkkey wants to merge 1 commit into
beetbox:mainfrom
Imkkey:fix-xdg-config-home-priority
Open

Imkkey wants to merge 1 commit into
beetbox:mainfrom
Imkkey:fix-xdg-config-home-priority

Conversation

@Imkkey

@Imkkey Imkkey commented Oct 13, 2026

Copy link
Copy Markdown

Fixes #98.

config_dirs() currently lists ~/.config before an explicit XDG_CONFIG_HOME. If both contain a configuration, the legacy path wins; if neither does, config_dir() creates the new directory under the legacy path. The usage guide describes the XDG location as first.

Place nonempty XDG_CONFIG_HOME first on Unix and macOS, then preserve the existing order of all other candidates. Windows and unset/empty-XDG fallback behavior stay unchanged. Expansion and deduplication continue through the existing code. This follows the narrow ordering approach discussed in #98 and #167; it does not remove legacy lookup paths or add new path validation.

Update the search-path documentation and add subprocess regressions with temporary homes. The cases cover existing configurations, new-directory fallback, empty/unset overrides, duplicate expanded paths, multiple system directories, application-specific overrides, macOS ordering and unchanged Windows paths. The macOS and Windows cases mock platform detection; no native-platform test result is claimed.

Two existing tests needed isolation fixes: FakeHome now saves/restores its temporary HOME/XDG environment, and the explicit-file reload test disables automatic configuration discovery. Without isolation, those tests can consult the machine's real configuration paths.

Validation on Python 3.12.14:

  • New tests before the fix: seven failures and 21 passing controls.
  • After: all 28 new cases, 44 focused path tests and 327 core tests pass.
  • Full suite: 328 passed and one pre-existing release-date failure. A pristine baseline in an isolated environment has 300 passes and the same failure in test_bump_version_applies_sequential_changelog_updates.
  • Ruff lint/format, full mypy targeting Python 3.10, strict Sphinx HTML build, documentation formatting/lint and git diff --check pass.

The production change is limited to util.config_dirs(). Pending #213 still obtains candidate paths through that function; its read-only discovery change is independent. The branches were not combined or tested together. Prepared and checked with OpenAI Codex assistance; draft for maintainer review.

@Imkkey
Imkkey marked this pull request as ready for review October 14, 2026 06:22

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

XDG_CONFIG_HOME, if set, should have priority over ~/.config and other platform-specific variants

1 participant