wtfutil/wtf · critical
panic(err)
Error message
panic(err)
What it means
On Windows, NewSystemInfo shells out to PowerShell (Get-CimInstance Win32_OperatingSystem).version to read the OS build for Windows 11 detection, and panics if the command fails. This fires when powershell.exe cannot be executed or errors — missing PATH, restricted execution policy, CIM/WMI service issues, or non-Windows builds accidentally compiled with this file. It runs during construction, so it crashes startup.
Source
Thrown at modules/system/system_info_windows.go:27
)
type SystemInfo struct {
ProductName string
ProductVersion string
BuildVersion string
}
// win11BuildNumber is the first Windows build number reported as Windows 11.
// Windows 11 kept the "10.0" major.minor version, so the build number is the
// only reliable signal Win32_OperatingSystem gives us to tell it apart from
// Windows 10.
const win11BuildNumber = 22000
func NewSystemInfo() *SystemInfo {
cmd := exec.Command("powershell.exe", "(Get-CimInstance Win32_OperatingSystem).version")
out, err := cmd.Output()
if err != nil {
panic(err)
}
productVersion, buildVersion := windowsProductVersion(string(out))
return &SystemInfo{
ProductName: "Windows",
ProductVersion: productVersion,
BuildVersion: buildVersion,
}
}
// windowsProductVersion turns the raw "major.minor.build" string reported by
// Win32_OperatingSystem into a human-friendly product version and separate
// build number. Windows 11 kept the "10.0" major.minor version, so the build
// number is the only reliable signal available to distinguish it from
// Windows 10.
func windowsProductVersion(rawVersion string) (productVersion, build string) {
s := strings.Split(strings.TrimSpace(rawVersion), ".")View on GitHub (pinned to bb838c1ccb)
Solutions
- Confirm powershell.exe is installed and on PATH: run the same command '(Get-CimInstance Win32_OperatingSystem).version' manually
- Fix PowerShell execution policy if it blocks command execution (Set-ExecutionPolicy or use -ExecutionPolicy Bypass semantics)
- Ensure the WMI/Winmgmt service is running (net start winmgmt) and repair WMI if corrupted
- If running as a service, give the service account access to powershell.exe and a valid PATH
- If the panic message is exec format/not found on Linux, you built with the wrong GOOS — rebuild for your platform
Example fix
// before (manual check fails) > powershell.exe (Get-CimInstance ...) 'powershell.exe' is not recognized // after > where.exe powershell.exe # add its directory to PATH, or reinstall Windows PowerShell
Defensive patterns
Strategy: fallback
Validate before calling
// verify the command works before the widget is constructed
out, err := exec.Command("powershell.exe", "(Get-CimInstance Win32_OperatingSystem).version").Output()
if err != nil {
log.Printf("powershell unavailable, windows version detection disabled: %v", err)
} Try / catch
func safeNewSystemInfo() (si *SystemInfo) {
defer func() {
if r := recover(); r != nil {
log.Printf("system info unavailable: %v", r)
si = nil // degrade gracefully
}
}()
return NewSystemInfo()
} Prevention
- Ensure powershell.exe is on PATH for the user/service running the app
- Keep the Winmgmt (WMI) service running and healthy
- Don't build the windows-specific system info file for non-Windows GOOS
- Prefer a build where version detection fails soft instead of panicking
When it happens
Trigger: NewSystemInfo is invoked and exec.Command("powershell.exe", ...).Output() returns an error: powershell.exe not on PATH, PowerShell blocked by policy or removed, WMI/CIM service (Winmgmt) stopped, or the binary built with the windows file on a non-Windows platform.
Common situations: Windows Server minimal installs without PowerShell, broken PATH for the service account running the app, PowerShell constrained-language/execution-policy environments, WMI repository corruption, cross-compilation mistakes including the _windows.go file on Linux.
Related errors
AI-assisted analysis of wtfutil/wtf@bb838c1ccb (2026-09-03).
Data as JSON: /api/errors/c765318f6a57dda6.
Report an issue: GitHub.