{"record":{"id":"3b2b918bfa8495df","repo":"lima-vm/lima","slug":"sysctl-unimplemented-on-windows","errorCode":null,"errorMessage":"sysctl: unimplemented on Windows","messagePattern":"sysctl: unimplemented on Windows","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/osutil/osutil_windows.go","lineNumber":76,"sourceCode":"}\n\nfunc Dup2(_ int, _ syscall.Handle) error {\n\treturn errors.New(\"unimplemented\")\n}\n\nfunc SignalName(sig os.Signal) string {\n\tswitch sig {\n\tcase syscall.SIGINT:\n\t\treturn \"SIGINT\"\n\tcase syscall.SIGTERM:\n\t\treturn \"SIGTERM\"\n\tdefault:\n\t\treturn fmt.Sprintf(\"Signal(%d)\", sig)\n\t}\n}\n\nfunc Sysctl(_ context.Context, _ string) (string, error) {\n\treturn \"\", errors.New(\"sysctl: unimplemented on Windows\")\n}\n\nfunc IsEACCES(err error) bool {\n\treturn errors.Is(err, syscall.ERROR_ACCESS_DENIED) || errors.Is(err, syscall.WSAEACCES)\n}\n","sourceCodeStart":58,"sourceCodeEnd":82,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/osutil/osutil_windows.go#L58-L82","documentation":"The Windows build of osutil.Sysctl is a stub that always returns this error, since Windows has no sysctl interface (that's a BSD/macOS kernel API). It exists to keep the cross-platform Sysctl function signature compilable on Windows.","triggerScenarios":"Any call to osutil.Sysctl(ctx, name) on a Windows build unconditionally returns errors.New(\"sysctl: unimplemented on Windows\") — there is no successful path.","commonSituations":"Shared code that reads kernel parameters via sysctl (e.g. detecting cgroup limits or kernel versions) running on a Windows host; cross-platform tooling developed on Linux/macOS then run on Windows.","solutions":["Gate sysctl reads behind runtime.GOOS checks and use the Windows registry / GetSystemInfo / WMI equivalents on Windows.","For kernel version info on Windows use golang.org/x/sys/windows RtlGetVersion instead of Sysctl.","Handle the error gracefully with a platform-appropriate default value."],"exampleFix":"// before\nv, err := osutil.Sysctl(ctx, \"kern.osrelease\")\n// after\nif runtime.GOOS == \"windows\" {\n    v = windowsKernelVersion() // RtlGetVersion\n} else {\n    v, err = osutil.Sysctl(ctx, \"kern.osrelease\")\n}","handlingStrategy":"fallback","validationCode":"if runtime.GOOS == \"windows\" {\n    // Sysctl always errors here; obtain the value via registry/WMI/RtlGetVersion instead\n}","typeGuard":"func sysctlSupported() bool { return runtime.GOOS == \"linux\" || runtime.GOOS == \"darwin\" }","tryCatchPattern":"v, err := osutil.Sysctl(ctx, name)\nif err != nil && strings.Contains(err.Error(), \"unimplemented on Windows\") {\n    v = windowsEquivalent(name) // registry/WMI fallback\n}","preventionTips":["Gate all Sysctl calls behind runtime.GOOS checks","Use golang.org/x/sys/windows (RtlGetVersion, registry) for kernel info on Windows","Return sensible defaults when sysctl is unavailable on a platform"],"tags":["windows","sysctl","unimplemented","portability"],"backgroundTag":"unimplemented-on-windows","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}