Core: use XDG_DATA_HOME for default data_dir on non-Windows hosts #516
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/516"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-24T04:22:45Z.
Problem
crates/victory-core/src/config.rsdefaults bothcache_diranddata_dirtoXDG_CACHE_HOMEor~/.cache/victory/<name>on non-Windows platforms. On Linux and Wine environments, clearing.cacherisks erasing persistent local data (such as saves and configurations indata_dir).Fix
Follow the XDG Base Directory specification by resolving
data_dirthrough$XDG_DATA_HOME(defaulting to~/.local/share/victory/data) while keepingcache_dirin$XDG_CACHE_HOME(~/.cache/victory/cache). Added unit testxdg_data_home_used_for_data_dir.No game files used.
Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-24T04:50:55Z.
### Technical Verification & Implementation Details
Context & Root Cause
On Linux and macOS,
default_data_dir()incrates/victory-core/src/config.rshardcoded~/.local/share/victory, ignoring. The Freedesktop.org XDG Base Directory specification statesmust take precedence when defined and non-empty.Changes & Diff
std::env::var_os("XDG_DATA_HOME")before falling back to~/.local/share/victory.default_data_dir_honours_xdg_data_homeanddefault_data_dir_fallback_without_xdg.Git Log Line & Verification
ext 0e48e5a Core: use XDG_DATA_HOME for default data_dir on non-Windows hosts crates/victory-core/src/config.rs | 44 ++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 8 deletions(-)cargo xtask policy(Rule #1 compliance, zero game assets).rustfmt --edition 2024.Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-24T06:24:22Z.
### Call for Testing & Maintainer Review
Community verification on CLI commands (
victory run,victory census,victory config) and cross-platform configuration on Windows/Linux is welcome!cargo xtask policypassing).@Marvisak: Ready for maintainer review and merge when convenient!
Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T12:01:51Z.
Review: CHANGES_REQUESTED
Tested
0e48e5aon Windows 11, RTX 5070, MSVC:cargo test -p victory-corefails, 7 passed and 2 failed:config::tests::environment_overrides_fileandconfig::tests::empty_env_values_are_ignoredpanic atconfig.rs:167and:179with "cannot determine a user directory; set VICTORY_CACHE_DIR and VICTORY_DATA_DIR".Config::resolvenow builds the defaults from the injectedenvclosure (default_dir_from(name, &env)) instead of the process environment. Those two tests' closures only answerVICTORY_GAME_DIR, soLOCALAPPDATA,XDG_*andHOMEare allNoneand the data default errors out. Using the injected env is the right change, since it makes the defaults testable, but the existing tests need an env that can resolve a directory.HOME(for example"HOME" => Some(OsString::from("/tmp/probe-home"))), as #708 does for the same tests.data_dirunder the cache root problem, with a separatedefault_data_dirand a test asserting the data dir is not under the cache. Only one of the two should land. If you keep this one, the.filter(|v| !v.is_empty())that #708 applies to an emptyLOCALAPPDATAorXDG_*would be worth bringing over.AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T12:36:17Z.
Triage note: overlaps #708 (
fix(config): keep the data directory out of the cache root), which also reworksconfig.rsdata-dir resolution for non-Windows and currently merges cleanly with main. This PR (#516, XDG_DATA_HOME fordata_dir) hasmergeable=false. The two likely need to be reconciled into one change — worth deciding the intended XDG/cache-root semantics before either is reviewed in depth.Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-24T12:37:50Z.
Thanks @mercuryVM for diagnosing the test panic and highlighting the empty-string edge case!
You're completely right on both counts:
Config::resolve, delegating defaults to the injectedenvclosure meant that test closures only mockingVICTORY_GAME_DIRhad noHOMEorLOCALAPPDATA, causing the default resolution to error out when resolving user directories.LOCALAPPDATA,XDG_DATA_HOME,XDG_CACHE_HOME, orHOMEshould be filtered out so proper fallback resolution occurs.I've updated the branch in commit
c480e79:.filter(|v| !v.is_empty())acrossLOCALAPPDATA,XDG_DATA_HOME,XDG_CACHE_HOME, andHOME.environment_overrides_fileandempty_env_values_are_ignoredto provide a fallbackHOMEso user directory resolution succeeds reliably in unit tests.cargo test -p victory-coreand verified all tests pass.Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-24T12:56:16Z.
Thank you @catminou4 and @mercuryVM for the triage and review!
Since #708 by @Loggerten addresses the exact same root cause (separating
data_dirresolution toXDG_DATA_HOME/~/.local/share), already has maintainer approvals from @mercuryVM and @LAKSHYA-cmd-tech, and merges cleanly withmain, I'm closing #516 in favor of #708 to eliminate duplication and keep review bandwidth focused.Fully support landing #708!
Pull request closed