From 5fc9fe3ba7b215d29d6dcff3c61ae2c67d6bb097 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Fri, 31 Oct 2025 15:25:22 -0300 Subject: [PATCH] fix: rethink global config path on windows: use `$HOME/.config` We made a mistake when it comes to the global config path on Windows. On macOS and Linux we use two different paths for data and config: `XDG_DATA_HOME` and `XDG_CONFIG_HOME`. On Windows though, we were using the same path for both data and config: `LOCALAPPDATA`. This caused confusion and means the user has no separate dir to store config separate of data. In theory we could consider something as `APPDATA`, but honestly, I propose that we just use `$HOME/.config`. It's easier to find and consistent with how other tools work. Git and other terminal tools also use `$HOME/.config`, so users are used to it. This is not a breaking change because the old path will still load, so existing setting will load as expected. Fixes #1347 --- README.md | 2 +- internal/config/load.go | 11 ----------- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/README.md b/README.md index 0b82aff4cc2e87ca181d8dfe1b11966cf658644b..b09dcdff75be9f4c95a84385c3a5213445b753cc 100644 --- a/README.md +++ b/README.md @@ -211,7 +211,7 @@ or globally, with the following priority: 1. `.crush.json` 2. `crush.json` -3. `$HOME/.config/crush/crush.json` (Windows: `%USERPROFILE%\AppData\Local\crush\crush.json`) +3. `$HOME/.config/crush/crush.json` Configuration itself is stored as a JSON object: diff --git a/internal/config/load.go b/internal/config/load.go index 0f4feeadf76e2113201c8aef563574cf2926cfbf..cc7e54393857084b232a93f70d765090a2b513a8 100644 --- a/internal/config/load.go +++ b/internal/config/load.go @@ -662,17 +662,6 @@ func GlobalConfig() string { return filepath.Join(xdgConfigHome, appName, fmt.Sprintf("%s.json", appName)) } - // return the path to the main config directory - // for windows, it should be in `%LOCALAPPDATA%/crush/` - // for linux and macOS, it should be in `$HOME/.config/crush/` - if runtime.GOOS == "windows" { - localAppData := os.Getenv("LOCALAPPDATA") - if localAppData == "" { - localAppData = filepath.Join(os.Getenv("USERPROFILE"), "AppData", "Local") - } - return filepath.Join(localAppData, appName, fmt.Sprintf("%s.json", appName)) - } - return filepath.Join(home.Dir(), ".config", appName, fmt.Sprintf("%s.json", appName)) }