{"record":{"id":"c52cd912c8dcdf01","repo":"hashicorp/nomad","slug":"cannot-generate-binary-install-path-s","errorCode":null,"errorMessage":"cannot generate binary install path - %s","messagePattern":"cannot generate binary install path - (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/windows_service_install.go","lineNumber":325,"sourceCode":"\n\treturn nil\n}\n\nfunc (c *WindowsServiceInstallCommand) binaryInstall(opts *windowsInstallOpts) error {\n\t// Get the path to the currently executing nomad. This\n\t// will be installed for the service to call.\n\texePath, err := os.Executable()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot detect current nomad path - %s\", err)\n\t}\n\n\t// Build the needed paths\n\tif opts.installDir == \"\" {\n\t\topts.installDir = winsvc.WINDOWS_INSTALL_BIN_DIRECTORY\n\t}\n\topts.installDir, err = c.winPaths.Expand(opts.installDir)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot generate binary install path - %s\", err)\n\t}\n\topts.binaryPath = filepath.Join(opts.installDir, \"nomad.exe\")\n\n\t// Ensure the install directory exists\n\tif err = c.winPaths.CreateDirectory(opts.installDir, false); err != nil {\n\t\treturn fmt.Errorf(\"could not create binary install directory - %s\", err)\n\t}\n\n\t// Create a new copy of the current binary to install\n\texeFile, err := os.Open(exePath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot open current nomad path for install - %s\", err)\n\t}\n\tdefer exeFile.Close()\n\n\t// Copy into a temporary file which can then be moved\n\t// into the correct location.\n\tdstFile, err := os.CreateTemp(os.TempDir(), \"nomad*\")","sourceCodeStart":307,"sourceCodeEnd":343,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/windows_service_install.go#L307-L343","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nnomad windows service install -install-dir \"%NOMAD_BIN%\"\n// after\nnomad windows service install -install-dir \"C:\\Program Files\\nomad\"","handlingStrategy":"validation","validationCode":"// Validate install dir before invoking\nif !filepath.IsAbs(installDir) || strings.Contains(installDir, \"%\") || strings.HasPrefix(installDir, \"~\") {\n    return errors.New(\"install-dir must be a fully-qualified absolute Windows path\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["windows","path","install-dir"],"backgroundTag":"path-resolution-failed","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}