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 |
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)