hashicorp/nomad · error

could not create binary install directory - %s

Error message

could not create binary install directory - %s

What it means

After expanding the install dir, binaryInstall ensures the directory exists via winPaths.CreateDirectory(opts.installDir, false). This error wraps that call's failure — Nomad cannot create the folder that will hold the installed service binary.

Source

Thrown at command/windows_service_install.go:331

	// 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
	exeFile, err := os.Open(exePath)
	if err != nil {
		return fmt.Errorf("cannot open current nomad path for install - %s", err)
	}
	defer exeFile.Close()

	// Copy into a temporary file which can then be moved
	// into the correct location.
	dstFile, err := os.CreateTemp(os.TempDir(), "nomad*")
	if err != nil {
		return fmt.Errorf("cannot create copy - %s", err)
	}
	defer dstFile.Close()

	if _, err = io.Copy(dstFile, exeFile); err != nil {

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Run the install from an elevated (Administrator) prompt
  2. Choose a writable -install-dir or use the default bin directory
  3. Check for a conflicting file at the install-dir path
  4. Verify the target drive exists and has free space

Example fix

// before (non-elevated)
nomad windows service install -install-dir "C:\Program Files\nomad"
// after (elevated shell)
nomad windows service install -install-dir "C:\Program Files\nomad"
Defensive patterns

Strategy: validation

Validate before calling

// Pre-check install dir writability and conflicts
if fi, err := os.Stat(installDir); err == nil && !fi.IsDir() {
    return fmt.Errorf("%s exists and is not a directory", installDir)
}
probe := filepath.Join(installDir, ".nomad_probe")
if err := os.WriteFile(probe, nil, 0o600); err != nil {
    return fmt.Errorf("install dir not writable: %w", err)
}
os.Remove(probe)

Prevention

When it happens

Trigger: Running 'nomad windows service install' when the install directory cannot be created: no write permission in the parent (e.g. Program Files without elevation), a file already exists at that path, or the drive is unavailable/read-only.

Common situations: Installing into C:\Program Files from a non-admin shell; custom -install-dir in a protected location; a file conflicting with the target directory name; full disk.

Related errors


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