hashicorp/nomad · error

Windows service manager is not supported on this platform

Error message

Windows service manager is not supported on this platform

What it means

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.

Source

Thrown at helper/winsvc/windows_service_nonwindows.go:14

// Copyright IBM Corp. 2015, 2026
// SPDX-License-Identifier: BUSL-1.1

//go:build !windows

package winsvc

import (
	"errors"
)

// NewWindowsServiceManager returns an error
func NewWindowsServiceManager() (WindowsServiceManager, error) {
	return nil, errors.New("Windows service manager is not supported on this platform")
}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Only construct the manager on Windows (build tags or runtime.GOOS check)
  2. Skip Windows service management logic entirely on non-Windows platforms
  3. Handle the error by falling back to the platform's native service mechanism (systemd, launchd)
  4. Verify the running GOOS if this error appears unexpectedly

Example fix

// before
mgr, err := winsvc.NewWindowsServiceManager()
if err != nil { return err }
// after
if runtime.GOOS != "windows" {
  return nil // not a Windows service context
}
mgr, err := winsvc.NewWindowsServiceManager()
Defensive patterns

Strategy: fallback

Validate before calling

if runtime.GOOS != "windows" {
  // skip Windows service manager entirely
  return nil
}

Try / catch

mgr, err := winsvc.NewWindowsServiceManager()
if err != nil {
  // not on Windows: use systemd/launchd path or no-op
  mgr = nil
}

Prevention

When it happens

Trigger: Calling helper/winsvc.NewWindowsServiceManager() on Linux/macOS (any build where the _nonwindows file is compiled).

Common situations: Agent startup code that installs/controls Windows services being run on Unix; portable binaries exercising Windows service management paths.

Related errors


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/74dd4dd162f843d1. Report an issue: GitHub.