{"record":{"id":"74dd4dd162f843d1","repo":"hashicorp/nomad","slug":"windows-service-manager-is-not-supported-on-this-p","errorCode":null,"errorMessage":"Windows service manager is not supported on this platform","messagePattern":"Windows service manager is not supported on this platform","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"helper/winsvc/windows_service_nonwindows.go","lineNumber":14,"sourceCode":"// Copyright IBM Corp. 2015, 2026\n// SPDX-License-Identifier: BUSL-1.1\n\n//go:build !windows\n\npackage winsvc\n\nimport (\n\t\"errors\"\n)\n\n// NewWindowsServiceManager returns an error\nfunc NewWindowsServiceManager() (WindowsServiceManager, error) {\n\treturn nil, errors.New(\"Windows service manager is not supported on this platform\")\n}\n","sourceCodeStart":1,"sourceCodeEnd":16,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/helper/winsvc/windows_service_nonwindows.go#L1-L16","documentation":"NewWindowsServiceManager on non-Windows platforms always returns this error; the Windows service control manager API only exists on Windows. The stub keeps the API surface compilable cross-platform while failing fast if invoked.","triggerScenarios":"Calling helper/winsvc.NewWindowsServiceManager() on Linux/macOS (any build where the _nonwindows file is compiled).","commonSituations":"Agent startup code that installs/controls Windows services being run on Unix; portable binaries exercising Windows service management paths.","solutions":["Only construct the manager on Windows (build tags or runtime.GOOS check)","Skip Windows service management logic entirely on non-Windows platforms","Handle the error by falling back to the platform's native service mechanism (systemd, launchd)","Verify the running GOOS if this error appears unexpectedly"],"exampleFix":"// before\nmgr, err := winsvc.NewWindowsServiceManager()\nif err != nil { return err }\n// after\nif runtime.GOOS != \"windows\" {\n  return nil // not a Windows service context\n}\nmgr, err := winsvc.NewWindowsServiceManager()","handlingStrategy":"fallback","validationCode":"if runtime.GOOS != \"windows\" {\n  // skip Windows service manager entirely\n  return nil\n}","typeGuard":null,"tryCatchPattern":"mgr, err := winsvc.NewWindowsServiceManager()\nif err != nil {\n  // not on Windows: use systemd/launchd path or no-op\n  mgr = nil\n}","preventionTips":["Only build/invoke Windows service management on windows GOOS","Structure service lifecycle code per-platform","Treat this error as a signal the wrong platform path executed"],"tags":["go","windows","platform","services"],"backgroundTag":"unsupported-platform-call","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}