{"record":{"id":"1b2bf084a0afce00","repo":"hashicorp/nomad","slug":"cannot-open-current-nomad-path-for-install-s","errorCode":null,"errorMessage":"cannot open current nomad path for install - %s","messagePattern":"cannot open current nomad path for install - (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/windows_service_install.go","lineNumber":337,"sourceCode":"\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*\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot create copy - %s\", err)\n\t}\n\tdefer dstFile.Close()\n\n\tif _, err = io.Copy(dstFile, exeFile); err != nil {\n\t\treturn fmt.Errorf(\"cannot write nomad binary for install - %s\", err)\n\t}\n\tdstFile.Close()\n\n\t// With a copy ready to be moved into place, ensure that\n\t// the path is clear then move the file.","sourceCodeStart":319,"sourceCodeEnd":355,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/windows_service_install.go#L319-L355","documentation":"To install the binary without disturbing the running executable, binaryInstall opens the current nomad.exe with os.Open(exePath) so it can be copied. This error wraps os.Open failure — the source executable cannot be read. Note the destination is copied via a temp file that is later moved into place.","triggerScenarios":"Running 'nomad windows service install' when os.Open(exePath) fails: the executable file was deleted/renamed after the process started, ACLs deny read access to it, or the path is invalid.","commonSituations":"Antivirus quarantining or deleting nomad.exe while running; replacing the binary mid-install; restrictive ACLs on the directory holding the running binary; network/UNC-hosted binary no longer accessible.","solutions":["Verify the running nomad.exe still exists on disk (Get-Process nomad | Select Path)","Re-extract a fresh nomad.exe and re-run the install from it","Check file ACLs (icacls) and grant read access to the installing user","Temporarily exclude nomad.exe from antivirus quarantine/real-time scanning"],"exampleFix":"// before: binary removed after launch\n// rename/delete nomad.exe while it runs, then:\nnomad windows service install  // cannot open current nomad path\n// after: run from an intact binary\nC:\\Ops\\nomad\\nomad.exe windows service install","handlingStrategy":"validation","validationCode":"// Verify the source executable is readable before install\nexePath, err := os.Executable()\nif err != nil {\n    return fmt.Errorf(\"cannot resolve executable: %w\", err)\n}\nf, err := os.Open(exePath)\nif err != nil {\n    return fmt.Errorf(\"current nomad binary not readable: %w\", err)\n}\nf.Close()","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not delete or replace nomad.exe while the installer runs","Add antivirus exclusions for the Nomad binary to prevent quarantine","Check ACLs (icacls) grant read access to the installing user","Run the installer from a locally stored binary, not a network share"],"tags":["windows","file","permissions"],"backgroundTag":"file-open-access-denied","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"}