Use XDG base directories and Known Folders on Windows (#1809)

This changes logic that previously read/wrote from `~/.pkl` to use
XDG base directories (all OSes), and Known Folders locations on Windows.

For example, Pkl will look for `settings.pkl` in:

1. `$XDG_CONFIG_HOME/pkl/settings.pkl`
2. `%APPDATA/pkl/settings.pkl`
3. `~/.pkl/settings.pkl`
4. Path pkl/settings/pkl within `$XDG_CONFIG_DIRS`
5. `/etc/xdg/pkl/settings.pkl`

---------

Co-authored-by: Florin Ungur <florin@florinungur.com>
This commit is contained in:
Daniel Chao
2026-08-20 21:50:24 +00:00
committed by GitHub
co-authored by Florin Ungur
parent 4dd37219c0
commit 6551a59f9e
24 changed files with 799 additions and 40 deletions
+10 -1
View File
@@ -17,8 +17,17 @@
/// Configuration settings for Pkl itself.
///
/// Every settings file must amend this module.
///
/// Unless CLI commands and build tool plugins are explicitly configured with a settings file,
/// they will use `~/.pkl/settings.pkl` or the defaults specified in this module.
/// they look in the following locations in order of precedence:
///
/// 1. `$XDG_CONFIG_HOME/pkl/settings.pkl`
/// 2. `$APPDATA/pkl/settings.pkl` (on Windows only)
/// 3. `~/.config/pkl/settings.pkl`
/// 4. Path `pkl/settings.pkl` within the `$XDG_CONFIG_DIRS` search path
/// (dirs separated by `:` on Unix, `;` on Windows).
/// 4. `/etc/xdg/pkl/settings.pkl`
/// 5. `~/.pkl/settings.pkl` (legacy location used by Pkl 0.32 and lower)
@ModuleInfo { minPklVersion = "0.33.0" }
module pkl.settings