fix(hal/windows): fall back to PowerShell CIM when wmic is unavailable#84
Closed
rjckkkkk wants to merge 1 commit into
Closed
fix(hal/windows): fall back to PowerShell CIM when wmic is unavailable#84rjckkkkk wants to merge 1 commit into
rjckkkkk wants to merge 1 commit into
Conversation
Recent Windows 11 builds ship without wmic, so CPU model, RAM, swap and CPU load all silently fell back to empty/zero (CPU model "", RAM 0) — e.g. on a Ryzen AI Max+ 395 box, hardware detection and the onboarding wizard showed no hardware info. wmic stays the primary probe (no change where it exists); when it errors, fall back to `powershell Get-CimInstance`, emitting the same unquoted header/data CSV the existing parsers already consume: - Win32_Processor -> Name/NumberOfCores/NumberOfLogicalProcessors/MaxClockSpeed - Win32_OperatingSystem -> TotalVisibleMemorySize/FreePhysicalMemory - Win32_PageFileUsage -> AllocatedBaseSize - Win32_Processor.LoadPercentage Also trims a possible UTF-8 BOM from PowerShell output before parsing. Tests (run on real Windows): CPU and RAM fall back to CIM when the wmic command is absent; existing wmic CSV parser tests unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Collaborator
Author
|
Closing as a duplicate of #78, which already replaces wmic with PowerShell CIM for CPU/RAM/pagefile/load AND adds AMD GPU (Win32_VideoController) detection — a strict superset of this PR. I reimplemented the CIM CPU/RAM fix here without spotting #78 first; #78 is the more complete fix and should land instead. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
internal/hal/detect_windows.godetects CPU model, RAM, swap, and CPU load by shelling out towmic. Recent Windows 11 builds no longer shipwmic, so every probe fails:Result on a Ryzen AI Max+ 395 box: hardware detection (and the onboarding wizard's hardware step) shows no CPU name / no RAM / no VRAM.
Fix
Keep
wmicas the primary probe (zero change on machines that have it); when it errors, fall back topowershell Get-CimInstance. Each CIM command emits the same unquotedheader\ndataCSV the existing wmic parsers already consume, so the parsing code is unchanged:Win32_Processor→ Name / NumberOfCores / NumberOfLogicalProcessors / MaxClockSpeedWin32_OperatingSystem→ TotalVisibleMemorySize / FreePhysicalMemoryWin32_PageFileUsage→ AllocatedBaseSizeWin32_Processor.LoadPercentageAlso trims a possible UTF-8 BOM from PowerShell output before parsing, and trims fields defensively.
Tests
detect_windows_test.go(build-taggedwindows): with the wmic command absent from the mock runner (→ErrNotFound),detectCPU/detectRAMfall back to the CIM commands and populate model/cores/threads/freq and total/available/swap. ExistingparseWMIC*CSV tests unchanged.Verified on real Windows 11 hardware (cross-compiled
go test -c, run on the box): all hal tests pass, andaima hal detectnow reports the CPU model + 128 GiB RAM where it previously returned empty/zero.