hashicorp/nomad · error

cannot generate configuration path - %s

Error message

cannot generate configuration path - %s

What it means

configInstall expands the user-supplied config directory path (e.g. with %ENV% variables or ~) using c.winPaths.Expand before creating directories. If Expand fails — the path cannot be resolved to an absolute Windows path — this error is returned. It means Nomad could not determine where the configuration should live.

Source

Thrown at command/windows_service_install.go:258

	if err := srvc.Start(); err != nil {
		return fmt.Errorf("could not start service - %w", err)
	}

	return nil
}

func (c *WindowsServiceInstallCommand) configInstall(opts *windowsInstallOpts) error {
	// If the config or data directory are unset, default them
	if opts.configDir == "" {
		opts.configDir = filepath.Join(winsvc.WINDOWS_INSTALL_APPDATA_DIRECTORY, "config")
	}
	if opts.dataDir == "" {
		opts.dataDir = filepath.Join(winsvc.WINDOWS_INSTALL_APPDATA_DIRECTORY, "data")
	}

	var err error
	if opts.configDir, err = c.winPaths.Expand(opts.configDir); err != nil {
		return fmt.Errorf("cannot generate configuration path - %s", err)
	}
	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"))

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Check the wrapped error to see which path failed to expand
  2. Pass a fully-qualified absolute path to -config-dir (e.g. C:\ProgramData\nomad)
  3. If using environment variables in the path, verify they are set for the installing user
  4. Omit -config-dir to use the default location

Example fix

// before
nomad windows service install -config-dir "%MY_UNDEFINED_VAR%\nomad"
// after
nomad windows service install -config-dir "C:\ProgramData\nomad"
Defensive patterns

Strategy: validation

Validate before calling

// Validate the config dir is an absolute Windows path before invoking
if !filepath.IsAbs(configDir) || strings.Contains(configDir, "%") || strings.HasPrefix(configDir, "~") {
    return errors.New("config-dir must be a fully-qualified absolute Windows path")
}

Prevention

When it happens

Trigger: Running 'nomad windows service install' with a -config-dir value that winPaths.Expand cannot resolve: malformed path syntax, an unset environment variable embedded in the path, or an unexpandable prefix.

Common situations: Passing '%APPDATA%\nomad' while the variable is undefined under the service account; using Unix-style ~ or forward slashes on Windows; quoting mistakes leaving literal % characters in the path.

Related errors


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/2f70989c6d731dae. Report an issue: GitHub.