{"record":{"id":"a74fcab44a9c216a","repo":"hashicorp/nomad","slug":"could-not-find-nomad-executable-v","errorCode":null,"errorMessage":"Could not find Nomad executable (%v)","messagePattern":"Could not find Nomad executable \\((.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"helper/discover/discover.go","lineNumber":61,"sourceCode":"\n\t// Check the CWD.\n\tpwd, err := os.Getwd()\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"Could not find Nomad executable (%v): %v\", nomadExe, err)\n\t}\n\n\tbin = filepath.Join(pwd, nomadExe)\n\tif _, err := os.Stat(bin); err == nil {\n\t\treturn bin, nil\n\t}\n\n\t// Check CWD/bin\n\tbin = filepath.Join(pwd, \"bin\", nomadExe)\n\tif _, err := os.Stat(bin); err == nil {\n\t\treturn bin, nil\n\t}\n\n\treturn \"\", fmt.Errorf(\"Could not find Nomad executable (%v)\", nomadExe)\n}\n\nfunc isNomad(path, nomadExe string) bool {\n\tif strings.HasSuffix(path, \".test\") || strings.HasSuffix(path, \".test.exe\") {\n\t\treturn false\n\t}\n\treturn true\n}\n","sourceCodeStart":43,"sourceCodeEnd":70,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/helper/discover/discover.go#L43-L70","documentation":"This is NomadExecutable()'s terminal failure: the running executable, the CWD, and CWD/bin were all checked and none contained a nomad binary named nomadExe. It means the test helper could not locate any nomad executable to launch or introspect.","triggerScenarios":"Calling NomadExecutable() (via NewTestServer, BeforeAll, Run, or intro-enforcement test helpers) when none of the three search paths yields the nomad binary — nomad is not built, not installed next to the test binary, and not in cwd or cwd/bin.","commonSituations":"Developer forgot to build the nomad binary before running tests (make dev/bootstrap); running only a subset of tests whose setup step normally fetches nomad; CI image lacking the nomad artifact; binary named differently (platform suffix mismatch like nomad.exe on non-Windows).","solutions":["Build the nomad binary into the current directory: run `make dev` (or `go build -o nomad .`) in the nomad repo root before testing.","Copy an existing nomad binary into the test's working directory or into a `bin/` subdirectory next to it.","Run tests from the repo root where the freshly built nomad binary resides.","Ensure the binary name matches the expected nomadExe for the platform (nomad vs nomad.exe)."],"exampleFix":"// before\n$ go test ./client/... # Error: Could not find Nomad executable (nomad)\n// after\n$ make dev  # builds ./nomad\n$ go test ./client/...","handlingStrategy":"validation","validationCode":"// Ensure a nomad binary exists where the helper looks before running tests\nexe := \"nomad\"\nif runtime.GOOS == \"windows\" { exe = \"nomad.exe\" }\nwd, _ := os.Getwd()\nif _, err := os.Stat(filepath.Join(wd, exe)); err != nil {\n\tif _, err := os.Stat(filepath.Join(wd, \"bin\", exe)); err != nil {\n\t\treturn fmt.Errorf(\"build nomad first: run 'make dev'; missing %s\", exe)\n\t}\n}","typeGuard":"func isNomadBinaryMissing(err error) bool {\n\treturn err != nil && strings.Contains(err.Error(), \"Could not find Nomad executable\") && !strings.Contains(err.Error(), \": \")\n}","tryCatchPattern":"bin, err := discover.NomadExecutable()\nif err != nil {\n\tt.Skipf(\"nomad binary not found; build it with 'make dev' (%v)\", err)\n}","preventionTips":["Run `make dev` (or `go build -o nomad .`) before running test suites","Keep the built binary in the test working directory or CWD/bin","Run tests from the repo root where CI expects the binary","Verify the platform-correct name (nomad vs nomad.exe) exists"],"tags":["discovery","missing-binary","testing","build"],"backgroundTag":"executable-not-found","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"}