{"record":{"id":"345115b62d0313e7","repo":"hashicorp/nomad","slug":"cannot-generate-data-path-s","errorCode":null,"errorMessage":"cannot generate data path - %s","messagePattern":"cannot generate data path - (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/windows_service_install.go","lineNumber":261,"sourceCode":"\n\treturn nil\n}\n\nfunc (c *WindowsServiceInstallCommand) configInstall(opts *windowsInstallOpts) error {\n\t// If the config or data directory are unset, default them\n\tif opts.configDir == \"\" {\n\t\topts.configDir = filepath.Join(winsvc.WINDOWS_INSTALL_APPDATA_DIRECTORY, \"config\")\n\t}\n\tif opts.dataDir == \"\" {\n\t\topts.dataDir = filepath.Join(winsvc.WINDOWS_INSTALL_APPDATA_DIRECTORY, \"data\")\n\t}\n\n\tvar err error\n\tif opts.configDir, err = c.winPaths.Expand(opts.configDir); err != nil {\n\t\treturn fmt.Errorf(\"cannot generate configuration path - %s\", err)\n\t}\n\tif opts.dataDir, err = c.winPaths.Expand(opts.dataDir); err != nil {\n\t\treturn fmt.Errorf(\"cannot generate data path - %s\", err)\n\t}\n\n\t// Ensure directories exist\n\tif err = c.winPaths.CreateDirectory(opts.configDir, true); err != nil {\n\t\treturn fmt.Errorf(\"cannot create configuration directory - %s\", err)\n\t}\n\n\tif err = c.winPaths.CreateDirectory(opts.dataDir, true); err != nil {\n\t\treturn fmt.Errorf(\"cannot create data directory - %s\", err)\n\t}\n\n\t// Check if any configuration files exist\n\tmatches, _ := filepath.Glob(filepath.Join(opts.configDir, \"*\"))\n\tif len(matches) < 1 {\n\t\tf, err := os.Create(filepath.Join(opts.configDir, \"config.hcl\"))\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"could not create default configuration file - %s\", err)\n\t\t}","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/windows_service_install.go#L243-L279","documentation":"configInstall expands the data directory path with c.winPaths.Expand (defaulting to the appdata data directory if unset). This error is returned when the data dir path cannot be resolved to a concrete Windows path. Nomad needs a valid data directory for the service to store state.","triggerScenarios":"Running 'nomad windows service install' with a -data-dir value that Expand cannot resolve: unset environment variable embedded in the path, malformed/unexpandable syntax, or non-Windows path forms.","commonSituations":"Custom -data-dir using a %VAR% that is undefined; relative or ~-style paths not expandable in the service context; typos in drive letters (e.g. 'D:\\' when D: doesn't exist).","solutions":["Check the wrapped error message for the unresolved path","Pass an absolute Windows path like C:\\ProgramData\\nomad\\data","Ensure any environment variables used in the path are defined","Omit -data-dir to use the default winsvc data directory"],"exampleFix":"// before\nnomad windows service install -data-dir \"%NOMAD_DATA%\"\n// after\nnomad windows service install -data-dir \"C:\\ProgramData\\nomad\\data\"","handlingStrategy":"validation","validationCode":"// Validate the data dir is an absolute Windows path before invoking\nif !filepath.IsAbs(dataDir) || strings.Contains(dataDir, \"%\") || strings.HasPrefix(dataDir, \"~\") {\n    return errors.New(\"data-dir must be a fully-qualified absolute Windows path\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass absolute Windows paths like C:\\ProgramData\\nomad\\data","Ensure referenced environment variables exist for the installing user","Omit -data-dir to use the built-in default"],"tags":["windows","data-dir","path"],"backgroundTag":"path-resolution-failed","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"}