Keep empty directory variables from redirecting saves and caches #596

Open
github-bot wants to merge 1 commit from github-bot/gh-596 into main AGit
Owner

@⁠shiaho777 on GitHub · 2026-12-04 13:06 UTC · original
shiaho777:fix/empty-user-dirs → main · +36 −11 · 1 files · 1 commits · open

With an empty LOCALAPPDATA, the default cache and save roots resolve to the relative paths victory/cache and victory/data. Launching from a different directory then selects a different save location. An empty XDG_CACHE_HOME likewise shadows an available home directory.

Use the existing nonempty path lookup for the three fallback variables. If every fallback is empty, report the existing configuration error. Explicit cache and data paths keep their precedence.

Verified with cargo test --locked -p victory-core (15 tests), Clippy for all targets in the crate, and cargo xtask policy. The regression tests exercise both an available home directory and an entirely empty environment.

**@⁠shiaho777** on GitHub · 2026-12-04 13:06 UTC · [original](https://github.com/readmet3xt-lab/foxhound/pull/596) `shiaho777:fix/empty-user-dirs` → `main` · +36 −11 · 1 files · 1 commits · open With an empty `LOCALAPPDATA`, the default cache and save roots resolve to the relative paths `victory/cache` and `victory/data`. Launching from a different directory then selects a different save location. An empty `XDG_CACHE_HOME` likewise shadows an available home directory. Use the existing nonempty path lookup for the three fallback variables. If every fallback is empty, report the existing configuration error. Explicit cache and data paths keep their precedence. Verified with `cargo test --locked -p victory-core` (15 tests), Clippy for all targets in the crate, and `cargo xtask policy`. The regression tests exercise both an available home directory and an entirely empty environment.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-04 13:11:15 +00:00
Author
Owner

@⁠fromthemoonx on GitHub · 2026-12-04 16:14 UTC · original

Works on native Windows: an empty LOCALAPPDATA no longer puts saves and caches in whatever folder the program was started from.

victory config, main against this PR, real debug builds. Only the variables named are set:

Environment main this PR
LOCALAPPDATA set under it the same
LOCALAPPDATA empty, HOME set relative victory\cache, victory\data under HOME\.cache\victory
XDG_CACHE_HOME empty, HOME set relative under HOME\.cache\victory
LOCALAPPDATA empty, nothing else relative exit 1, "cannot determine a user directory; set VICTORY_CACHE_DIR and VICTORY_DATA_DIR"
all three empty relative the same error
all three empty, both VICTORY_*_DIR given the given folders the same

Tested at a9578a45, which sits directly on current main (5e44415b). Windows 11 Pro, Ryzen 7 5700X, RTX 3060 12 GB.

  • cargo test --workspace --locked --no-fail-fast: 1402 passed, 0 failed, 51 ignored.
  • Both CI Clippy commands (default and --all-features) and cargo xtask policy: clean.
  • The new tests guard the fix: I undid it five ways (both folders, cache only, data only, empty XDG_CACHE_HOME accepted, empty HOME accepted), and at least one of the two new tests failed each time.

Outside this PR, from reading only: load_mods (apps/victory/src/main.rs), installed_place (victory-profile) and file_physical_dir (victory-hle) also take an empty LOCALAPPDATA as a folder. load_mods is the one I'd look at first, since it would load DLLs from a victory\mods under the current folder. Fine as a separate change.

Not tested: starting a title, the launcher, Linux or Wine.

AI use: Claude Code (Claude Opus 5.5) ran the tests, read the diff and wrote this report.

**@⁠fromthemoonx** on GitHub · 2026-12-04 16:14 UTC · [original](https://github.com/readmet3xt-lab/foxhound/pull/596#issuecomment-7417112737) Works on native Windows: an empty `LOCALAPPDATA` no longer puts saves and caches in whatever folder the program was started from. **`victory config`, `main` against this PR**, real debug builds. Only the variables named are set: | Environment | `main` | this PR | |---|---|---| | `LOCALAPPDATA` set | under it | the same | | `LOCALAPPDATA` empty, `HOME` set | relative `victory\cache`, `victory\data` | under `HOME\.cache\victory` | | `XDG_CACHE_HOME` empty, `HOME` set | relative | under `HOME\.cache\victory` | | `LOCALAPPDATA` empty, nothing else | relative | exit 1, "cannot determine a user directory; set VICTORY_CACHE_DIR and VICTORY_DATA_DIR" | | all three empty | relative | the same error | | all three empty, both `VICTORY_*_DIR` given | the given folders | the same | **Tested** at `a9578a45`, which sits directly on current `main` (`5e44415b`). Windows 11 Pro, Ryzen 7 5700X, RTX 3060 12 GB. - `cargo test --workspace --locked --no-fail-fast`: 1402 passed, 0 failed, 51 ignored. - Both CI Clippy commands (default and `--all-features`) and `cargo xtask policy`: clean. - The new tests guard the fix: I undid it five ways (both folders, cache only, data only, empty `XDG_CACHE_HOME` accepted, empty `HOME` accepted), and at least one of the two new tests failed each time. **Outside this PR, from reading only:** `load_mods` (`apps/victory/src/main.rs`), `installed_place` (`victory-profile`) and `file_physical_dir` (`victory-hle`) also take an empty `LOCALAPPDATA` as a folder. `load_mods` is the one I'd look at first, since it would load DLLs from a `victory\mods` under the current folder. Fine as a separate change. **Not tested:** starting a title, the launcher, Linux or Wine. **AI use:** Claude Code (Claude Opus 5.5) ran the tests, read the diff and wrote this report.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/596/head:github-bot/gh-596'
git switch 'github-bot/gh-596'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-596'
git switch 'github-bot/gh-596'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-596'
git switch 'github-bot/gh-596'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-596'
git switch 'main'
git merge --squash 'github-bot/gh-596'
git switch 'main'
git merge --ff-only 'github-bot/gh-596'
git switch 'main'
git merge 'github-bot/gh-596'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.