hashicorp/nomad · error
cannot install new nomad binary - %s
Error message
cannot install new nomad binary - %s
What it means
binaryInstall wraps the error from os.Rename(dstFile.Name(), opts.binaryPath), which moves the staged temp copy to the final install path. On Windows, rename across devices or onto a locked target fails, so the new binary could not be installed. The wrapped error explains why.
Source
Thrown at command/windows_service_install.go:361
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
- Ensure the temp directory and the install path are on the same volume (set TMP accordingly)
- Stop the running nomad service so the target path is not locked
- Run elevated so the rename is permitted
- Remove any residual file at the target path manually, then retry the install
Example fix
// before: TMP on D: while binaryPath on C: set TMP=D:\tmp // after: same volume as install target set TMP=C:\Windows\Temp
Defensive patterns
Strategy: validation
Validate before calling
td := os.TempDir()
if filepath.VolumeName(td) != filepath.VolumeName(binaryPath) {
return fmt.Errorf("temp dir %s and install path %s on different volumes", td, binaryPath)
} Try / catch
if err := installCmd.Run(); err != nil {
if strings.Contains(err.Error(), "cannot install new nomad binary") {
// align TMP volume with install path, unlock target, retry
}
} Prevention
- Keep TMP on the same volume as the install directory
- Clear any residual file at the target path before install
- Stop the running service so the target is not locked
When it happens
Trigger: os.Rename fails when the temp dir and binaryPath are on different volumes (rename is not cross-device on Windows), the target path still exists/is locked, or permissions deny the move during binaryInstall.
Common situations: TMP on a different drive than the install directory; leftover target file that RemoveAll missed; target locked by the still-running service.
Related errors
- Windows directory creation not supported on this platform
- cannot create copy - %s
- cannot write nomad binary for install - %s
- cannot remove existing nomad binary install - %s
- EventLogger is not supported on this platform
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/10f5524a4709b75b.
Report an issue: GitHub.