hashicorp/nomad · error

Windows path expansion not supported on this platform

Error message

Windows path expansion not supported on this platform

What it means

The non-Windows windowsPaths implementation of Expand always returns this error, since Windows-style environment/path expansion is meaningless off-Windows. It is a fail-fast stub for the cross-platform interface.

Source

Thrown at helper/winsvc/path_nonwindows.go:17

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

//go:build !windows

package winsvc

import "errors"

func NewWindowsPaths() WindowsPaths {
	return &windowsPaths{}
}

type windowsPaths struct{}

func (w *windowsPaths) Expand(string) (string, error) {
	return "", errors.New("Windows path expansion not supported on this platform")
}

func (w *windowsPaths) CreateDirectory(string, bool) error {
	return errors.New("Windows directory creation not supported on this platform")
}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Use the platform-appropriate Paths implementation; expansion is only valid on Windows
  2. Guard the call with runtime.GOOS == "windows" or a build-tagged abstraction
  3. Use os.ExpandEnv or filepath utilities for portable path expansion on Unix
  4. Confirm the process isn't mistakenly built to use windowsPaths on non-Windows

Example fix

// before
p, _ := winsvc.NewPaths() // windowsPaths on Linux
out, err := p.Expand("%APPDATA%\\svc")
// after
if runtime.GOOS != "windows" {
  out = os.ExpandEnv("$HOME/.svc")
} else {
  out, err = p.Expand("%APPDATA%\\svc")
}
Defensive patterns

Strategy: fallback

Validate before calling

if runtime.GOOS != "windows" {
  expanded := os.ExpandEnv(rawPath)
}

Try / catch

out, err := paths.Expand(p)
if err != nil {
  out = os.ExpandEnv(p) // portable fallback
}

Prevention

When it happens

Trigger: Calling windowsPaths.Expand(path) (via the Paths interface) on a non-Windows platform; code that uses the Windows path helpers compiled for Linux/macOS.

Common situations: Shared code that expands service paths without checking GOOS; running Windows service provisioning logic on Unix.

Related errors


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