{"record":{"id":"ea992395d79fd424","repo":"hashicorp/nomad","slug":"could-not-create-default-configuration-file-s","errorCode":null,"errorMessage":"could not create default configuration file - %s","messagePattern":"could not create default configuration file - (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/windows_service_install.go","lineNumber":278,"sourceCode":"\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}\n\t\tfmt.Fprintf(f, strings.TrimSpace(`\n# Full configuration options can be found at https://developer.hashicorp.com/nomad/docs/configuration\n\ndata_dir  = \"%s\"\nbind_addr = \"0.0.0.0\"\n\nserver {\n  # license_path is required for Nomad Enterprise as of Nomad v1.1.1+\n  #license_path = \"%s\\license.hclic\"\n  enabled          = true\n  bootstrap_expect = 1\n}\n\nclient {\n  enabled = true\n  servers = [\"127.0.0.1\"]\n}","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/windows_service_install.go#L260-L296","documentation":"If the config directory is empty (no glob matches), configInstall seeds it with a default config.hcl via os.Create. This error wraps failure of that file creation — the directory exists but the file could not be opened for writing. The install aborts with no default configuration written.","triggerScenarios":"Running 'nomad windows service install' into an empty-but-unwritable config dir: ACL denies write to the installing user, the directory is on read-only media, antivirus locks config.hcl, or path/quota issues.","commonSituations":"Installing as a non-admin user into a directory owned by another account; Group Policy-restricted ProgramData ACLs; antivirus intercepting new .hcl files; disk full.","solutions":["Run the installer from an elevated (Administrator) prompt","Manually pre-create config.hcl in the config dir with valid Nomad configuration (then the seed step is skipped)","Check ACLs on the config directory (icacls) and grant the installing user write access","Verify antivirus is not blocking file creation and disk has space"],"exampleFix":"// before: let installer seed file, fails on ACLs\nnomad windows service install\n// after: pre-create the config yourself\n// C:\\> Set-Content C:\\ProgramData\\nomad\\config.hcl 'data_dir = \"C:/ProgramData/nomad/data\"'\n// C:\\> nomad windows service install","handlingStrategy":"validation","validationCode":"// Pre-check that config.hcl can be created in the target dir\nprobe := filepath.Join(configDir, \".nomad_probe\")\nif err := os.WriteFile(probe, nil, 0o600); err != nil {\n    return fmt.Errorf(\"config dir not writable: %w\", err)\n}\nos.Remove(probe)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Grant write ACLs to the config directory for the installer","Pre-create config.hcl yourself to skip the seed step","Configure antivirus exclusions for the Nomad install paths","Install as Administrator"],"tags":["windows","configuration-file","permissions"],"backgroundTag":"file-write-permission-denied","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"}