fix(hw-oracle): ignore a relative XDG_CACHE_HOME when choosing the build cache #12815

Merged
rooklz merged 1 commit from upstream-pr/12815 into main 2026-11-02 16:13:30 +00:00
rooklz commented 2026-10-29 10:59:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-29T10:59:18Z.


What

hw_oracle.py picked its build cache as HW_ORACLE_CACHE, then $XDG_CACHE_HOME/anyps5-hw-oracle, then ~/.cache/anyps5-hw-oracle, and it used XDG_CACHE_HOME exactly as given. The XDG Base Directory specification says a relative path in these variables is invalid and must be ignored. With a relative value, the oracle was built under whatever directory the tool happened to start in. This PR moves the choice into cache_directory(environment), which falls back to ~/.cache when XDG_CACHE_HOME is relative. HW_ORACLE_CACHE keeps its current behaviour: it overrides everything, is used as given, and an empty value falls through. docs/dev/HW_ORACLE.md (the cache sentence from #12719) now says "unset, empty or relative".

CacheDirectoryTests checks 7 environments (unset, empty, relative/cache, ., absolute, an override with a relative XDG value, an empty override with an absolute XDG value). It also checks the module-level CACHE by importing it in a subprocess with a relative XDG_CACHE_HOME. On main's hw_oracle.py the new tests fail with 7 errors and 1 failure; with this change all pass.

Tested

  • macOS arm64: python -m unittest test_hw_oracle OK (skipped=3) on /usr/bin/python3 (3.9), Homebrew 3.13 and 3.15.
  • Relinker-only Release build + ctest: 489/489.
  • check_conventions.py --base upstream/main passed; pr_overlap.py --branch fix/hw-oracle-relative-xdg-cache probed 1388 open PRs. 3 share files and all 3 merge cleanly, so there is no overlap.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5066767910 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12815). Originally posted by [rooklz](https://github.com/rooklz) on 2026-10-29T10:59:18Z. --- ### What `hw_oracle.py` picked its build cache as `HW_ORACLE_CACHE`, then `$XDG_CACHE_HOME/anyps5-hw-oracle`, then `~/.cache/anyps5-hw-oracle`, and it used `XDG_CACHE_HOME` exactly as given. The XDG Base Directory specification says a relative path in these variables is invalid and must be ignored. With a relative value, the oracle was built under whatever directory the tool happened to start in. This PR moves the choice into `cache_directory(environment)`, which falls back to `~/.cache` when `XDG_CACHE_HOME` is relative. `HW_ORACLE_CACHE` keeps its current behaviour: it overrides everything, is used as given, and an empty value falls through. `docs/dev/HW_ORACLE.md` (the cache sentence from #12719) now says "unset, empty or relative". `CacheDirectoryTests` checks 7 environments (unset, empty, `relative/cache`, `.`, absolute, an override with a relative XDG value, an empty override with an absolute XDG value). It also checks the module-level `CACHE` by importing it in a subprocess with a relative `XDG_CACHE_HOME`. On main's `hw_oracle.py` the new tests fail with 7 errors and 1 failure; with this change all pass. ### Tested - macOS arm64: `python -m unittest test_hw_oracle` OK (skipped=3) on /usr/bin/python3 (3.9), Homebrew 3.13 and 3.15. - Relinker-only Release build + `ctest`: 489/489. - `check_conventions.py --base upstream/main` passed; `pr_overlap.py --branch fix/hw-oracle-relative-xdg-cache` probed 1388 open PRs. 3 share files and all 3 merge cleanly, so there is no overlap. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's technical debt file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
malekaifa commented 2026-10-29 11:25:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by malekaifa on 2026-10-29T11:25:43Z.

Review: APPROVED


Reviewed exact head 1a9ee6ff904b639c7584a2614fce91612a565c4a. I independently reproduced the base behavior with XDG_CACHE_HOME=relative/cache: current main selects relative\cache\anyps5-hw-oracle. On this head, Windows Python 3.12 falls back to C:\Users\Malek\.cache\anyps5-hw-oracle; the two CacheDirectoryTests pass; the full hw-oracle suite passes on Python 3.12 and 3.9 (50 tests, 4 platform skips each); conventions and diff-check are clean. I also copied the exact head into WSL/Python 3.12.3: relative XDG_CACHE_HOME falls back to /home/malek/.cache/anyps5-hw-oracle, both focused tests pass, and the full suite passes 50 tests with 2 expected skips. The explicit HW_ORACLE_CACHE override remains unchanged. I found no blocking issue in the cache-directory change.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5696906275 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12815#pullrequestreview-5696906275). Originally posted by [malekaifa](https://github.com/malekaifa) on 2026-10-29T11:25:43Z. **Review:** APPROVED --- Reviewed exact head 1a9ee6ff904b639c7584a2614fce91612a565c4a. I independently reproduced the base behavior with XDG_CACHE_HOME=relative/cache: current main selects relative\\cache\\anyps5-hw-oracle. On this head, Windows Python 3.12 falls back to C:\\Users\\Malek\\.cache\\anyps5-hw-oracle; the two CacheDirectoryTests pass; the full hw-oracle suite passes on Python 3.12 and 3.9 (50 tests, 4 platform skips each); conventions and diff-check are clean. I also copied the exact head into WSL/Python 3.12.3: relative XDG_CACHE_HOME falls back to /home/malek/.cache/anyps5-hw-oracle, both focused tests pass, and the full suite passes 50 tests with 2 expected skips. The explicit HW_ORACLE_CACHE override remains unchanged. I found no blocking issue in the cache-directory change.
malekaifa commented 2026-10-30 11:32:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by malekaifa on 2026-10-30T11:32:16Z.

Review: APPROVED


Re-checked exact current head da7dfe55c743f444fcb71ce67aae40919169c847. hw_oracle.py, test_hw_oracle.py and docs/dev/HW_ORACLE.md are byte-identical to the exact head I previously reviewed, so the cache-directory behavior and regression are unchanged. Current-main merge-tree is clean and git diff --check passes. My prior Windows/WSL relative-XDG_CACHE_HOME reproduction and full-suite validation still apply. No blocking issue found on this pure rebase.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5711608108 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12815#pullrequestreview-5711608108). Originally posted by [malekaifa](https://github.com/malekaifa) on 2026-10-30T11:32:16Z. **Review:** APPROVED --- Re-checked exact current head da7dfe55c743f444fcb71ce67aae40919169c847. hw_oracle.py, test_hw_oracle.py and docs/dev/HW_ORACLE.md are byte-identical to the exact head I previously reviewed, so the cache-directory behavior and regression are unchanged. Current-main merge-tree is clean and git diff --check passes. My prior Windows/WSL relative-XDG_CACHE_HOME reproduction and full-suite validation still apply. No blocking issue found on this pure rebase.
malekaifa commented 2026-10-30 18:22:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by malekaifa on 2026-10-30T18:22:52Z.

Review: APPROVED


Re-checked exact current head f45cb5f380 after the latest rebase. The three reviewed files (tools/hw-oracle/hw_oracle.py, tools/hw-oracle/test_hw_oracle.py, docs/dev/HW_ORACLE.md) are byte-identical to previously approved head da7dfe55c743f444fcb71ce67aae40919169c847. Current-main cde94eb55a merge-tree is clean (tree 00c4fae78154de5e9ccf3c536719ba03947ba4e8), and git diff --check passes. My prior Windows/WSL reproduction and full-suite validation still apply. No blocking issue found on this pure rebase.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5716827918 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12815#pullrequestreview-5716827918). Originally posted by [malekaifa](https://github.com/malekaifa) on 2026-10-30T18:22:52Z. **Review:** APPROVED --- Re-checked exact current head f45cb5f380b02d2f00ec85059f4345d23656e6ab after the latest rebase. The three reviewed files (tools/hw-oracle/hw_oracle.py, tools/hw-oracle/test_hw_oracle.py, docs/dev/HW_ORACLE.md) are byte-identical to previously approved head da7dfe55c743f444fcb71ce67aae40919169c847. Current-main cde94eb55a654012543ed4bc9df8b63e9f9a0b3b merge-tree is clean (tree 00c4fae78154de5e9ccf3c536719ba03947ba4e8), and git diff --check passes. My prior Windows/WSL reproduction and full-suite validation still apply. No blocking issue found on this pure rebase.
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
boykopovar/AnyPS5!12815
No description provided.