hashicorp/nomad · error
could not create default configuration file - %s
Error message
could not create default configuration file - %s
What it means
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.
Source
Thrown at command/windows_service_install.go:278
if opts.dataDir, err = c.winPaths.Expand(opts.dataDir); err != nil {
return fmt.Errorf("cannot generate data path - %s", err)
}
// Ensure directories exist
if err = c.winPaths.CreateDirectory(opts.configDir, true); err != nil {
return fmt.Errorf("cannot create configuration directory - %s", err)
}
if err = c.winPaths.CreateDirectory(opts.dataDir, true); err != nil {
return fmt.Errorf("cannot create data directory - %s", err)
}
// Check if any configuration files exist
matches, _ := filepath.Glob(filepath.Join(opts.configDir, "*"))
if len(matches) < 1 {
f, err := os.Create(filepath.Join(opts.configDir, "config.hcl"))
if err != nil {
return fmt.Errorf("could not create default configuration file - %s", err)
}
fmt.Fprintf(f, strings.TrimSpace(`
# Full configuration options can be found at https://developer.hashicorp.com/nomad/docs/configuration
data_dir = "%s"
bind_addr = "0.0.0.0"
server {
# license_path is required for Nomad Enterprise as of Nomad v1.1.1+
#license_path = "%s\license.hclic"
enabled = true
bootstrap_expect = 1
}
client {
enabled = true
servers = ["127.0.0.1"]
}View on GitHub (pinned to 482b49bf1a)
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
Example fix
// before: let installer seed file, fails on ACLs nomad windows service install // after: pre-create the config yourself // C:\> Set-Content C:\ProgramData\nomad\config.hcl 'data_dir = "C:/ProgramData/nomad/data"' // C:\> nomad windows service install
Defensive patterns
Strategy: validation
Validate before calling
// Pre-check that config.hcl can be created in the target dir
probe := filepath.Join(configDir, ".nomad_probe")
if err := os.WriteFile(probe, nil, 0o600); err != nil {
return fmt.Errorf("config dir not writable: %w", err)
}
os.Remove(probe) Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Permission denied" / "Failed to write" file errors: why a library can't write its files to disk (EACCES, EPERM, ENOSPC) and how to fix them — this error's family across 43 libraries.
Related errors
- service registration check failed - %w
- unable to create service - %w
- cannot create configuration directory - %s
- cannot create data directory - %s
- could not create binary install directory - %s
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/ea992395d79fd424.
Report an issue: GitHub.