Repository navigation
Core: ignore empty LOCALAPPDATA, XDG_CACHE_HOME, and HOME in default directory resolution - #2579
reeledMarek wants to merge 1 commit into
Conversation
…directory resolution
49f72ee to
61349a7
Compare
There was a problem hiding this comment.
Verified on Linux (Rust 1.99.0)
Branch: current main (13f91ca) + this PR (merges cleanly; it also merges cleanly with #2578).
cargo test --locked -p victory-core: 14 passed.- With the
.filter(|v| !v.is_empty())indefault_dir_fromremoved (refactor kept),default_dir_ignores_empty_user_env_varsfails. So the test pins the fix. cargo clippy --locked --target x86_64-pc-windows-msvc -p victory-core --all-targets -- -D warnings: clean, same as main.
Review
The fix is correct, and it makes default_dir consistent with resolve's own env_path, which already drops empty values (config.rs:85). No defect found.
Prior art: the same fix was in #243 ("Config: skip an empty or relative cache base for the default directories"), which was folded into #241. #241 was then closed unmerged yesterday after a needs-rebase triage. So nothing on main covers this, and this PR is the live version. Two small follow-ups, either here or later:
- Relative values. #243 also skipped relative bases. The XDG Base Directory spec says implementations should treat a relative path in these variables as invalid and ignore it.
XDG_CACHE_HOME=foostill yieldsfoo/victory/cacheunder the working directory here, which is usually the checkout, andsubdirthen fails with the asset-policy error. Adding.filter(|p| p.is_absolute())togetwould cover it. - Hermetic
resolve.Config::resolvetakes an injectableenv, but its fallback still callsdefault_dir, which reads the real process environment (config.rs:93-97). Passingresolve'senvthrough todefault_dir_fromwould make the existingresolvetests independent of the host'sLOCALAPPDATA/HOME.
Not verified
- Windows runtime behaviour with an empty
LOCALAPPDATA. Only the logic is covered, through the injected env.
Reviewed with Claude Code.
|
Automated triage for the maintainers. Merge candidate (small). In CI: Generated by Claude Code |
|
Independent native Windows verification of this PR at Environment: Windows 11 Pro x64 ( I built the same standalone probe against each checkout. Each case invokes
The five negative-control failures are:
Main returns relative paths for these cases; this PR produces the expected No game files, GPU or gameplay used. No production code changes or duplicate AI-assisted verification and probe authoring with OpenAI Codex. This is a |
fuzeofficlal
left a comment
There was a problem hiding this comment.
Looks good. Verified merged onto main (63bcca43) on Windows 11:
default_dir_from(crates/victory-core/src/config.rs:147-159) cleanly filters empty values via.filter(|v| !v.is_empty()), matching the existingenv_pathandexplicit_config_pathconventions inconfig.rsand preserving non-UTF-8OsStringpaths.cargo xtask policy(191 files ok),cargo clippy --locked -p victory-core --all-targets -- -D warnings(default and--all-features), andcargo test --locked -p victory-core(14/14, includingdefault_dir_ignores_empty_user_env_vars) all pass.- Additional verification passed across the full 27-state
(LOCALAPPDATA, XDG_CACHE_HOME, HOME)x{unset, "", valid}matrix, a Windows unpaired-surrogateOsStringpath check, and 3 real Windows 11 child-processConfig::load()checks confirming emptyLOCALAPPDATAfalls through toXDG_CACHE_HOME, thenHOME/.cache, and returnsErrwhen all three are empty.
(Non-blocking note: Config::resolve still calls default_dir directly rather than threading its env closure into default_dir_from, which is fine as-is and can be left for a separate cleanup if ever needed.)
Summary
In
victory-core/src/config.rs, empty environment variables (LOCALAPPDATA="",XDG_CACHE_HOME="",HOME="") were treated as valid base paths, causing default cache/config directories to resolve to relative paths under the current working directory instead of falling back properly.Now empty values are ignored during default directory resolution.
Testing
cargo test -p victory-core --locked(14/14 passed, including synthetic tests for empty env values)cargo clippy -p victory-core --all-targets --target x86_64-pc-windows-msvc --locked -- -D warnings(clean)cargo test -p xtask --locked(6/6 passed)