hashicorp/nomad · error

cannot detect current nomad path - %s

Error message

cannot detect current nomad path - %s

What it means

binaryInstall calls os.Executable() to locate the currently running nomad.exe, which will be copied into the service install directory. This error wraps failure of os.Executable() — the runtime could not determine the path of the running process, so the binary to install is unknown.

Source

Thrown at command/windows_service_install.go:316

log_level = "WARN"
eventlog {
  enabled = true
  level   = "ERROR"
}
`), strings.ReplaceAll(opts.dataDir, `\`, `\\`), strings.ReplaceAll(opts.configDir, `\`, `\\`))
		f.Close()
		c.Ui.Output(fmt.Sprintf("  Added initial configuration file: %s", f.Name()))
	}

	return nil
}

func (c *WindowsServiceInstallCommand) binaryInstall(opts *windowsInstallOpts) error {
	// Get the path to the currently executing nomad. This
	// will be installed for the service to call.
	exePath, err := os.Executable()
	if err != nil {
		return fmt.Errorf("cannot detect current nomad path - %s", err)
	}

	// Build the needed paths
	if opts.installDir == "" {
		opts.installDir = winsvc.WINDOWS_INSTALL_BIN_DIRECTORY
	}
	opts.installDir, err = c.winPaths.Expand(opts.installDir)
	if err != nil {
		return fmt.Errorf("cannot generate binary install path - %s", err)
	}
	opts.binaryPath = filepath.Join(opts.installDir, "nomad.exe")

	// Ensure the install directory exists
	if err = c.winPaths.CreateDirectory(opts.installDir, false); err != nil {
		return fmt.Errorf("could not create binary install directory - %s", err)
	}

	// Create a new copy of the current binary to install

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Re-launch nomad from a stable on-disk location and retry the install
  2. Verify the running nomad.exe still exists at its original path (Get-Process nomad | Select Path)
  3. Avoid launching the installer from temp directories or deleted symlinks
  4. Re-download/re-extract a fresh nomad.exe if the binary is corrupted

Example fix

// before: launched from a since-deleted temp copy
C:\Users\x\AppData\Local\Temp\nomad.exe windows service install
// after: run from a stable install location
C:\Ops\nomad\nomad.exe windows service install
Defensive patterns

Strategy: validation

Validate before calling

// Verify the running executable resolves to an existing file before install
exePath, err := os.Executable()
if err != nil {
    return fmt.Errorf("cannot resolve current executable: %w", err)
}
if _, err := os.Stat(exePath); err != nil {
    return fmt.Errorf("current executable no longer on disk: %w", err)
}

Prevention

When it happens

Trigger: Running 'nomad windows service install' when os.Executable() fails: the executable was deleted/renamed after launch, the process was started via a deleted symlink, or unusual launch mechanisms (packed/loaded images) that defeat path lookup.

Common situations: Deleting or replacing nomad.exe while it runs; launching nomad from a temporary directory that was cleaned up; running from a UNC/ephemeral path removed mid-session; exotic process launchers.

Related errors


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