hashicorp/nomad · error

cannot write nomad binary for install - %s

Error message

cannot write nomad binary for install - %s

What it means

binaryInstall wraps the error from io.Copy, which streams the nomad executable into the temporary file. The source binary could not be fully read or written, so the install aborts before the file is moved into place. The wrapped error identifies whether read or write failed.

Source

Thrown at command/windows_service_install.go:350

	}

	// 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 {
		return fmt.Errorf("cannot write nomad binary for install - %s", err)
	}
	dstFile.Close()

	// With a copy ready to be moved into place, ensure that
	// the path is clear then move the file.
	if err = os.RemoveAll(opts.binaryPath); err != nil {
		return fmt.Errorf("cannot remove existing nomad binary install - %s", err)
	}

	if err = os.Rename(dstFile.Name(), opts.binaryPath); err != nil {
		return fmt.Errorf("cannot install new nomad binary - %s", err)
	}

	return nil
}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Read the wrapped I/O error to see if the read or write side failed
  2. Free disk space on the temp drive
  3. Ensure no process has the source nomad binary exclusively locked and retry the install
  4. Retry after antivirus finishes scanning the binary
Defensive patterns

Strategy: try-catch

Try / catch

if err := installCmd.Run(); err != nil {
    var werr error
    if strings.Contains(err.Error(), "cannot write nomad binary") {
        // free disk space, verify source binary is not locked, retry
        _ = werr
    }
}

Prevention

When it happens

Trigger: io.Copy(dstFile, exeFile) fails because the source nomad.exe is locked, unreadable, the exeFile was closed early, or the destination temp file hits a full disk / I/O error during binaryInstall.

Common situations: Another process (running nomad service, antivirus scan) holds the source binary open; disk fills mid-copy; corrupted or truncated source binary.

Related errors


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