hashicorp/nomad · error
unable to configure service - %w
Error message
unable to configure service - %w
What it means
Wraps the failure of `srvc.Configure` when the Nomad service already exists and is being updated (start type, display name, description, binary path). The underlying ChangeServiceConfig error is chained with %w.
Source
Thrown at command/windows_service_install.go:212
if err != nil {
return fmt.Errorf("service registration check failed - %w", err)
}
// If the service already exists, open it and update. Otherwise
// create a new service.
if exists {
srvc, err = m.GetService(winsvc.WINDOWS_SERVICE_NAME)
if err != nil {
return fmt.Errorf("unable to get existing service - %w", err)
}
defer srvc.Close()
if err := srvc.Configure(winsvc.WindowsServiceConfiguration{
StartType: winsvc.StartAutomatic,
DisplayName: winsvc.WINDOWS_SERVICE_DISPLAY_NAME,
Description: winsvc.WINDOWS_SERVICE_DESCRIPTION,
BinaryPathName: cmd,
}); err != nil {
return fmt.Errorf("unable to configure service - %w", err)
}
} else {
srvc, err = m.CreateService(winsvc.WINDOWS_SERVICE_NAME, opts.binaryPath,
winsvc.WindowsServiceConfiguration{
StartType: winsvc.StartAutomatic,
DisplayName: winsvc.WINDOWS_SERVICE_DISPLAY_NAME,
Description: winsvc.WINDOWS_SERVICE_DESCRIPTION,
BinaryPathName: cmd,
},
)
if err != nil {
return fmt.Errorf("unable to create service - %w", err)
}
defer srvc.Close()
}
// Enable the service in the Windows eventlog
if err := srvc.EnableEventlog(); err != nil {View on GitHub (pinned to 482b49bf1a)
Solutions
- Run the install from an elevated shell
- Quote the binary path (opts.binaryPath) if it contains spaces
- `sc.exe delete nomad`, reboot, then fresh install instead of update
- Verify the chained cause: ERROR_ACCESS_DENIED vs ERROR_INVALID_PARAMETER
Example fix
// before
cmd := fmt.Sprintf("%s agent -config %s", opts.binaryPath, opts.configDir)
// after
cmd := fmt.Sprintf("\"%s\" agent -config \"%s\"", opts.binaryPath, opts.configDir) Defensive patterns
Strategy: validation
Validate before calling
if strings.ContainsAny(opts.binaryPath, " \t") {
log.Printf("warning: binary path contains spaces: %q — ensure the SCM command line is quoted", opts.binaryPath)
}
out, _ := exec.Command("sc.exe", "qc", "nomad").CombinedOutput()
log.Printf("current service config: %s", out) Try / catch
if err := srvc.Configure(cfg); err != nil {
if errors.Is(err, windows.ERROR_ACCESS_DENIED) { /* elevate and retry */ }
return fmt.Errorf("unable to configure service - %w", err)
} Prevention
- Quote binary paths containing spaces in the SCM command string
- Run the update path from an elevated shell
- Delete + recreate the service if updates keep failing
- Validate the binary path exists before Configure
When it happens
Trigger: Updating the existing Nomad service's configuration via ChangeServiceConfig fails — access denied, invalid binary path (e.g. unquoted path with spaces), or service handle closed.
Common situations: Non-elevated run attempting to change an existing service; opts.binaryPath contains spaces that break the SCM command string; service is marked for deletion.
Related errors
- unable to stop existing service - %w
- configuration install failed - %w
- service install failed - %w
- service registration check failed - %w
- unable to get existing service - %w
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/ef8017d3bc62989c.
Report an issue: GitHub.