{"record":{"id":"6d05a1026ffe5adb","repo":"hashicorp/nomad","slug":"cannot-detect-current-nomad-path-s","errorCode":null,"errorMessage":"cannot detect current nomad path - %s","messagePattern":"cannot detect current nomad path - (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/windows_service_install.go","lineNumber":316,"sourceCode":"log_level = \"WARN\"\neventlog {\n  enabled = true\n  level   = \"ERROR\"\n}\n`), strings.ReplaceAll(opts.dataDir, `\\`, `\\\\`), strings.ReplaceAll(opts.configDir, `\\`, `\\\\`))\n\t\tf.Close()\n\t\tc.Ui.Output(fmt.Sprintf(\"  Added initial configuration file: %s\", f.Name()))\n\t}\n\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","sourceCodeStart":298,"sourceCodeEnd":334,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/windows_service_install.go#L298-L334","documentation":"binaryInstall calls os.Executable() to locate the currently running nomad.exe, which will be copied into the service install directory. This error wraps failure of os.Executable() — the runtime could not determine the path of the running process, so the binary to install is unknown.","triggerScenarios":"Running 'nomad windows service install' when os.Executable() fails: the executable was deleted/renamed after launch, the process was started via a deleted symlink, or unusual launch mechanisms (packed/loaded images) that defeat path lookup.","commonSituations":"Deleting or replacing nomad.exe while it runs; launching nomad from a temporary directory that was cleaned up; running from a UNC/ephemeral path removed mid-session; exotic process launchers.","solutions":["Re-launch nomad from a stable on-disk location and retry the install","Verify the running nomad.exe still exists at its original path (Get-Process nomad | Select Path)","Avoid launching the installer from temp directories or deleted symlinks","Re-download/re-extract a fresh nomad.exe if the binary is corrupted"],"exampleFix":"// before: launched from a since-deleted temp copy\nC:\\Users\\x\\AppData\\Local\\Temp\\nomad.exe windows service install\n// after: run from a stable install location\nC:\\Ops\\nomad\\nomad.exe windows service install","handlingStrategy":"validation","validationCode":"// Verify the running executable resolves to an existing file before install\nexePath, err := os.Executable()\nif err != nil {\n    return fmt.Errorf(\"cannot resolve current executable: %w\", err)\n}\nif _, err := os.Stat(exePath); err != nil {\n    return fmt.Errorf(\"current executable no longer on disk: %w\", err)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run the installer from a stable, on-disk nomad.exe location","Never launch installs from temp dirs or transient symlinks","Avoid deleting/renaming the binary while it runs"],"tags":["windows","executable","os"],"backgroundTag":"executable-not-found-in-path","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"}