Keep empty directory variables from redirecting saves and caches #596

Open
shiaho777 wants to merge 1 commit from upstream-pr/596 into main
shiaho777 commented 2026-12-04 13:06:45 +00:00 (Migrated from github.com)

Imported from readmet3xt-lab/foxhound. Originally posted by shiaho777 on 2026-12-04T13:06:45Z.


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.

<!-- greyfinch-sync:readmet3xt-lab/foxhound:issue:5647027600 --> Imported from [readmet3xt-lab/foxhound](https://github.com/readmet3xt-lab/foxhound/pull/596). Originally posted by [shiaho777](https://github.com/shiaho777) on 2026-12-04T13:06:45Z. --- 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.
fromthemoonx commented 2026-12-04 16:14:41 +00:00 (Migrated from github.com)

Imported from readmet3xt-lab/foxhound. Originally posted by fromthemoonx on 2026-12-04T16:14:41Z.


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.

<!-- greyfinch-sync:readmet3xt-lab/foxhound:comment:7417112737 --> Imported from [readmet3xt-lab/foxhound](https://github.com/readmet3xt-lab/foxhound/pull/596#issuecomment-7417112737). Originally posted by [fromthemoonx](https://github.com/fromthemoonx) on 2026-12-04T16:14:41Z. --- 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 cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/596:upstream-pr/596'
git switch 'upstream-pr/596'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/596'
git switch 'upstream-pr/596'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/596'
git switch 'upstream-pr/596'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/596'
git switch 'main'
git merge --squash 'upstream-pr/596'
git switch 'main'
git merge --ff-only 'upstream-pr/596'
git switch 'main'
git merge 'upstream-pr/596'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
readmet3xt-lab/foxhound!596
No description provided.