{"record":{"id":"a6479bbdeb4ef30d","repo":"hashicorp/nomad","slug":"windows-directory-creation-not-supported-on-this-p","errorCode":null,"errorMessage":"Windows directory creation not supported on this platform","messagePattern":"Windows directory creation not supported on this platform","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"helper/winsvc/path_nonwindows.go","lineNumber":21,"sourceCode":"\n//go:build !windows\n\npackage winsvc\n\nimport \"errors\"\n\nfunc NewWindowsPaths() WindowsPaths {\n\treturn &windowsPaths{}\n}\n\ntype windowsPaths struct{}\n\nfunc (w *windowsPaths) Expand(string) (string, error) {\n\treturn \"\", errors.New(\"Windows path expansion not supported on this platform\")\n}\n\nfunc (w *windowsPaths) CreateDirectory(string, bool) error {\n\treturn errors.New(\"Windows directory creation not supported on this platform\")\n}\n","sourceCodeStart":3,"sourceCodeEnd":23,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/helper/winsvc/path_nonwindows.go#L3-L23","documentation":"The non-Windows windowsPaths implementation of CreateDirectory always returns this error; directory creation via the Windows service path helper is unsupported off-Windows. Fail-fast stub for the cross-platform interface.","triggerScenarios":"Calling windowsPaths.CreateDirectory(path, ...) via the Paths interface on Linux/macOS.","commonSituations":"Service setup code creating working directories regardless of OS; running Windows service install logic on Unix.","solutions":["Use os.MkdirAll on non-Windows platforms instead of the winsvc helper","Guard directory creation with a runtime.GOOS or build-tag check","Route setup through a platform abstraction that picks the correct implementation","Verify which Paths implementation the running binary uses"],"exampleFix":"// before\nerr := paths.CreateDirectory(dir, true)\n// after\nif runtime.GOOS == \"windows\" {\n  err = paths.CreateDirectory(dir, true)\n} else {\n  err = os.MkdirAll(dir, 0o755)\n}","handlingStrategy":"fallback","validationCode":"if runtime.GOOS != \"windows\" {\n  err := os.MkdirAll(dir, 0o755)\n}","typeGuard":null,"tryCatchPattern":"err := paths.CreateDirectory(dir, true)\nif err != nil {\n  err = os.MkdirAll(dir, 0o755) // portable fallback\n}","preventionTips":["Use os.MkdirAll directly on non-Windows platforms","Abstract directory setup behind a per-platform implementation","GOOS-gate all winsvc filesystem helpers"],"tags":["go","windows","platform","filesystem"],"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"}