{"record":{"id":"8dafbce3e0d0fde5","repo":"hashicorp/nomad","slug":"failed-to-detect-executable-v","errorCode":null,"errorMessage":"failed to detect executable: %v","messagePattern":"failed to detect executable: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"helper/subproc/self.go","lineNumber":25,"sourceCode":"\t\"fmt\"\n\t\"os\"\n\t\"os/exec\"\n\t\"strings\"\n\t\"sync\"\n)\n\nvar (\n\t// executable is the executable of this process\n\texecutable string\n\tonce       sync.Once\n)\n\n// Self returns the path to the executable of this process.\nfunc Self() string {\n\tonce.Do(func() {\n\t\ts, err := os.Executable()\n\t\tif err != nil {\n\t\t\tpanic(fmt.Sprintf(\"failed to detect executable: %v\", err))\n\t\t}\n\n\t\t// when running tests, we need to use the real nomad binary,\n\t\t// and make sure you recompile between changes!\n\t\tif strings.HasSuffix(s, \".test\") {\n\t\t\tif s, err = exec.LookPath(\"nomad\"); err != nil {\n\t\t\t\tpanic(fmt.Sprintf(\"failed to find nomad binary: %v\", err))\n\t\t\t}\n\t\t}\n\t\texecutable = s\n\t})\n\treturn executable\n}\n","sourceCodeStart":7,"sourceCodeEnd":39,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/helper/subproc/self.go#L7-L39","documentation":"Self() resolves the current process executable path via os.Executable() inside a sync.Once and caches it. If os.Executable() fails, the process panics immediately because Nomad cannot locate its own binary to relaunch helper subprocesses (drivers, exec tasks). This is a programming/environment-level failure, not a recoverable runtime error.","triggerScenarios":"Calling helper/subproc.Self() (directly or via any code that spawns subprocesses) when os.Executable() returns an error, e.g. the executable file was deleted after the process started, or the OS lookup fails.","commonSituations":"Running a Nomad binary that was replaced/deleted on disk while running (package upgrades), running in restricted container environments where /proc cannot be read, or unusual exec environments where /proc/self/exe is unavailable.","solutions":["Restore the deleted or moved binary at its original path, or restart the process from a valid binary location","Check that /proc is mounted and readable (Linux) so /proc/self/exe resolution works","Run Nomad in a standard filesystem environment; avoid exotic chroot setups that hide the executable","Update Nomad; if reproducible in a normal environment, file a bug with the wrapped os.Executable() error"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if _, err := os.Executable(); err != nil { /* restart from a known-good binary or abort before calling subproc users */ }","typeGuard":null,"tryCatchPattern":"defer func() { if r := recover(); r != nil { if s, ok := r.(string); ok && strings.Contains(s, \"failed to detect executable\") { log.Fatalf(\"environment error: %v\", s) }; panic(r) } }()","preventionTips":["Never delete/replace the running binary in place; use atomic rename installs","Ensure /proc is mounted in containers","Restart the agent promptly after binary upgrades"],"tags":["panic","filesystem","process"],"backgroundTag":"executable-path-lookup-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"}