{"record":{"id":"9208cde60090cbd1","repo":"hashicorp/nomad","slug":"failed-to-find-nomad-binary-v","errorCode":null,"errorMessage":"failed to find nomad binary: %v","messagePattern":"failed to find nomad binary: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"helper/subproc/self.go","lineNumber":32,"sourceCode":"var (\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":14,"sourceCodeEnd":39,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/helper/subproc/self.go#L14-L39","documentation":"When the running process is a Go test binary (name ends with .test), Self() substitutes the real 'nomad' binary found via exec.LookPath so tests can spawn real subprocesses. If 'nomad' is not on PATH, the process panics. This only affects test environments.","triggerScenarios":"Running Nomad's Go test suite (or any test linking helper/subproc) where the compiled test binary has a .test suffix and no 'nomad' binary is discoverable via the PATH environment variable.","commonSituations":"Running 'go test ./...' without having built/installed the nomad binary, having a stale or deleted nomad binary on PATH, or running tests with a stripped PATH (CI containers).","solutions":["Build the nomad binary ('go build -o nomad .') and add it to PATH before running tests (source comments: recompile between changes)","Run tests via the repo's Makefile 'make test' target, which handles building nomad first","Verify PATH inside the test environment includes the directory containing the nomad binary"],"exampleFix":"// before\ngo test ./helper/subproc/...\n// after\ngo build -o ./bin/nomad . && PATH=\"$(pwd)/bin:$PATH\" go test ./helper/subproc/...","handlingStrategy":"validation","validationCode":"if _, err := exec.LookPath(\"nomad\"); err != nil { t.Skipf(\"nomad binary not on PATH: %v\", err) }","typeGuard":null,"tryCatchPattern":"defer func() { if r := recover(); r != nil { if s, ok := r.(string); ok && strings.Contains(s, \"failed to find nomad binary\") { t.Fatalf(\"build nomad and add to PATH: %v\", s) }; panic(r) } }()","preventionTips":["Run tests via 'make test' which builds nomad first","Verify PATH in CI containers","Rebuild the nomad binary after code changes"],"tags":["panic","testing","path"],"backgroundTag":"missing-binary-on-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"}