Skip to content

fix(examine): stop the Windows install scans disagreeing with each other - #219

Merged
volen-silo merged 1 commit into
mainfrom
fix/windows-install-scanners
Aug 12, 2026
Merged

volen-silo merged 1 commit into
mainfrom
fix/windows-install-scanners

Conversation

@volen-silo

Copy link
Copy Markdown
Collaborator
  • If this PR fixes a bug, searched tests/e2e-cucumber/expectations.toml for the fixed ticket ID and removed/narrowed any now-stale xfail rows. No row references this behaviour — it has no e2e seam (see below).

Branches off main, independent of the #216 → #217 → #218 stack.

Summary

Three independent implementations answered "where is ROCm installed" on Windows, and they disagreed on every axis that matters. Two of them become the shared resolver — the one already used by examine's install summary, the JSON probe, and fix-6-path on Linux.

search roots ordering validates an install?
resolver C:\Program Files\AMD\ROCm, C:\Program Files\ROCm numeric yes
probe_hip_sdk_windows C:\Program Files\AMD\ROCm lexicographic no
newest_rocm_install_dir C:\Program Files\AMD\ROCm, C:\Program Files (x86)\AMD\ROCm lexicographic no

So with 6.2 and 6.10 both installed, rocm fix fix-6-path put the older SDK on PATH — and because the third scanner accepted any directory whose name began with a digit, an empty leftover could go on PATH too.

Both now order by numeric component, search the same roots as the rest of the CLI, require an install marker, and honour $ROCM_PATH — which neither did before.

$HIP_PATH still wins in the SDK probe: it names the SDK specifically, where the resolver answers the broader question. The reported SDK version now comes from what the install says about itself, falling back to the directory name only for a $HIP_PATH pointing somewhere unversioned.

Checked before narrowing: the resolver's marker gate accepts bin/rocminfo.exe, bin/hipcc.bat and bin/amdhip64*.dll, so a real Windows HIP SDK still matches. This tightens what counts as an install without losing a genuine one — worth confirming, since a marker list written for Linux would have quietly broken Windows detection.

Test plan

Two new tests, driven through fix-6-path's own resolver call rather than re-testing the resolver:

  • a planted install named by $ROCM_PATH is found;
  • an empty directory named by $ROCM_PATH is not.

Both are discriminating rather than decorative — the scanner they replace ignored $ROCM_PATH outright and looked only under C:\Program Files, so both fail against it on any host. That matters here because the change cannot be exercised on Linux at all.

cargo test -p rocm-core: 261 pass; the two proc_lifecycle::tests::tree_* failures are the known WSL2-local issue and reproduce unchanged on main. cargo fmt --all --check, workspace clippy --all-targets -D warnings, and the prek hygiene hooks are clean.

Verification gap, stated plainly. This has no e2e seam: the search directories are hardcoded constants with no override, so the harness can only plant a single install via $ROCM_PATH — which bypasses directory scanning and therefore ordering entirely. The Strix Halo Windows lane exercises the code path but cannot plant two versions to order. Unit tests against planted directories are the coverage; a reviewer should not read a green Windows lane as proof the ordering is right.

cargo xtask e2e on this branch reports the two diagnose scenarios failing — that is the known WSL2-local noise this branch does not carry the fix for (#216 adds @requires-bare-metal), not a regression from this change, which touches Windows-only code paths.

🤖 Generated with Claude Code

Three independent implementations answered "where is ROCm installed" on
Windows, and they disagreed on every axis that matters. Two of them are now
the shared resolver, which is the one already used by examine's install
summary, the JSON probe and fix-6-path on Linux.

`probe_hip_sdk_windows` scanned a single directory with `versions.sort()`, so
`6.2` outranked `6.10`. `newest_rocm_install_dir`, which fix-6-path reaches on
Windows, searched `C:\Program Files (x86)\AMD\ROCm` where the resolver searches
`C:\Program Files\ROCm`, sorted the same wrong way, and accepted any directory
whose name began with a digit -- so an empty leftover could be put on a user's
PATH.

Both now order by numeric component, search the same roots as the rest of the
CLI, require an install marker, and honour `$ROCM_PATH`, which neither did
before. `$HIP_PATH` still wins in the SDK probe: it names the SDK specifically,
where the resolver answers the broader question. The SDK version now comes from
what the install says about itself, falling back to the directory name only for
a `$HIP_PATH` pointing somewhere unversioned.

The marker gate was checked against a real Windows layout before being applied
here: `rocminfo.exe`, `hipcc.bat` and `bin/amdhip64*.dll` are all accepted, so
this narrows what counts as an install without losing a genuine one.

Tested through fix-6-path's own resolver call rather than the resolver again:
the replaced scanner ignored `$ROCM_PATH` entirely and looked only under
`C:\Program Files`, so both new tests fail against it on any host -- one
proving a planted install is found, one proving an empty directory is not.

Signed-off-by: Eugene Volen <Eugene.Volen@amd.com>
@juhovainio

Copy link
Copy Markdown
Collaborator

Reviewed this against the live code (not just the diff) and it holds up.

  • probe_hip_sdk_windows (examine.rs) and newest_rocm_install_dir (fix.rs) both now delegate to discover_rocm_installs() (lib.rs), which I traced end to end: search roots match the PR's description (C:\Program Files\AMD\ROCm, C:\Program Files\ROCm), $ROCM_PATH takes precedence over both, and versioned installs sort newest-first by numeric component (rocm_version_sort_key), not lexicographically - so 6.10 correctly outranks 6.2 where the old scanners got this backwards.
  • The install-marker gate (legacy_rocm_candidate_exists) accepts bin/rocminfo, bin/rocminfo.exe, bin/hipcc, bin/hipcc.bat, lib/libamdhip64.so, lib/libhsa-runtime64.so, .info/version, or any bin/amdhip64*.dll - confirms the "rocminfo.exe, hipcc.bat and bin/amdhip64*.dll are all accepted" claim, and confirms the new test's bare bin/rocminfo marker is genuinely sufficient.
  • $HIP_PATH still short-circuits before the resolver runs in probe_hip_sdk_windows, matching the stated precedence, and hip_sdk_version now prefers rocm_install_version() (reads .info/version*) with directory-name as fallback only, as described.
  • runtime_is_windows() is a const fn backed by a compile-time cfg!-style Platform, so on Linux CI discover_rocm_installs() deterministically resolves to the Linux search dirs/layout - the two new fix.rs tests only rely on $ROCM_PATH overriding that entirely, so they're genuinely platform-independent despite testing "Windows" scanner logic.
  • The new tests' real-ROCM_PATH-mutation pattern (unsafe { std::env::set_var(...) }, save/restore, no serialization) matches an existing, already-accepted pattern elsewhere in this file's test suite (the ROCM_CLI_ENGINE_ENVS_ROOT tests), so it's consistent with project convention rather than a new flakiness risk.

CI is green across every lane including both Windows jobs. The PR is upfront about the one real gap - two-install ordering isn't exercised by any CI lane since the search dirs are hardcoded with no override seam - and that's a reasonable thing to leave as a stated gap rather than block on, given the existing discover_rocm_installs_in/_in_layout test seam already covers the ordering logic itself at the unit level.

Looks safe to approve after final validation.

@volen-silo
volen-silo added this pull request to the merge queue Aug 12, 2026
Merged via the queue into main with commit 02248a1 Aug 12, 2026
23 checks passed
@volen-silo
volen-silo deleted the fix/windows-install-scanners branch August 12, 2026 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants