hashicorp/nomad · error
cannot generate binary install path - %s
Error message
cannot generate binary install path - %s
What it means
binaryInstall expands the installation directory (defaulting to winsvc.WINDOWS_INSTALL_BIN_DIRECTORY) with c.winPaths.Expand to get an absolute path for placing nomad.exe. This error wraps failure of that expansion — the binary install path cannot be resolved.
Source
Thrown at command/windows_service_install.go:325
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
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*")View on GitHub (pinned to 482b49bf1a)
Solutions
- Check the wrapped error for which path failed
- Pass an absolute Windows path to -install-dir (e.g. C:\Program Files\nomad)
- Define any environment variables used in the path before installing
- Omit -install-dir to use the default WINDOWS_INSTALL_BIN_DIRECTORY
Example fix
// before nomad windows service install -install-dir "%NOMAD_BIN%" // after nomad windows service install -install-dir "C:\Program Files\nomad"
Defensive patterns
Strategy: validation
Validate before calling
// Validate install dir before invoking
if !filepath.IsAbs(installDir) || strings.Contains(installDir, "%") || strings.HasPrefix(installDir, "~") {
return errors.New("install-dir must be a fully-qualified absolute Windows path")
} Prevention
- Use absolute Windows paths for -install-dir
- Define any env vars referenced in the path
- Use the default bin directory when unsure
- Quote paths properly in PowerShell/cmd
When it happens
Trigger: Running 'nomad windows service install' with a custom -install-dir that Expand cannot resolve: undefined environment variable embedded in the path, malformed/unexpandable syntax, or non-absolute path forms.
Common situations: Custom -install-dir using %VAR% that is unset for the installing user; Unix-style path syntax on Windows; literal % characters from shell quoting issues; typo'd drive letters.
Related errors
- Windows path expansion not supported on this platform
- cannot generate configuration path - %s
- cannot generate data path - %s
- path cannot contain template delimiters or parenthesis
- eventlog.level must be one of INFO, WARN, or ERROR
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/c52cd912c8dcdf01.
Report an issue: GitHub.