Skip to content

Core: ignore empty LOCALAPPDATA, XDG_CACHE_HOME, and HOME in default directory resolution - #2579

Open
reeledMarek wants to merge 1 commit into
Marvisak:mainfrom
reeledMarek:fix/core-config-default-dir-empty-env
Open

reeledMarek wants to merge 1 commit into
Marvisak:mainfrom
reeledMarek:fix/core-config-default-dir-empty-env

Conversation

@reeledMarek

Copy link
Copy Markdown
Contributor

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)

@reeledMarek
reeledMarek force-pushed the fix/core-config-default-dir-empty-env branch from 49f72ee to 61349a7 Compare November 25, 2026 20:05

@lcg007xd-c lcg007xd-c left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()) in default_dir_from removed (refactor kept), default_dir_ignores_empty_user_env_vars fails. 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:

  1. 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=foo still yields foo/victory/cache under the working directory here, which is usually the checkout, and subdir then fails with the asset-policy error. Adding .filter(|p| p.is_absolute()) to get would cover it.
  2. Hermetic resolve. Config::resolve takes an injectable env, but its fallback still calls default_dir, which reads the real process environment (config.rs:93-97). Passing resolve's env through to default_dir_from would make the existing resolve tests independent of the host's LOCALAPPDATA/HOME.

Not verified

  • Windows runtime behaviour with an empty LOCALAPPDATA. Only the logic is covered, through the injected env.

Reviewed with Claude Code.

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Merge candidate (small). In victory-core/src/config.rs, default_dir took an empty LOCALAPPDATA, XDG_CACHE_HOME or HOME as a base. That gave a relative victory/<name> under the current folder. Now empty values fall through to the next variable, and then to the existing "set VICTORY_CACHE_DIR and VICTORY_DATA_DIR" error. This matches how the same file already treats empty VICTORY_GAME_DIR/VICTORY_CONFIG (see its existing tests). The default_dir_from split with an injected env follows the file's pattern, and the test covers both the fallback and the error.

CI: check passing. Merges cleanly into current main. A recommendation to look at it, not an approval.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants