hashicorp/nomad · error

Could not find Nomad executable (%v)

Error message

Could not find Nomad executable (%v)

What it means

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.

Source

Thrown at helper/discover/discover.go:61

	// Check the CWD.
	pwd, err := os.Getwd()
	if err != nil {
		return "", fmt.Errorf("Could not find Nomad executable (%v): %v", nomadExe, err)
	}

	bin = filepath.Join(pwd, nomadExe)
	if _, err := os.Stat(bin); err == nil {
		return bin, nil
	}

	// Check CWD/bin
	bin = filepath.Join(pwd, "bin", nomadExe)
	if _, err := os.Stat(bin); err == nil {
		return bin, nil
	}

	return "", fmt.Errorf("Could not find Nomad executable (%v)", nomadExe)
}

func isNomad(path, nomadExe string) bool {
	if strings.HasSuffix(path, ".test") || strings.HasSuffix(path, ".test.exe") {
		return false
	}
	return true
}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Build the nomad binary into the current directory: run `make dev` (or `go build -o nomad .`) in the nomad repo root before testing.
  2. Copy an existing nomad binary into the test's working directory or into a `bin/` subdirectory next to it.
  3. Run tests from the repo root where the freshly built nomad binary resides.
  4. Ensure the binary name matches the expected nomadExe for the platform (nomad vs nomad.exe).

Example fix

// before
$ go test ./client/... # Error: Could not find Nomad executable (nomad)
// after
$ make dev  # builds ./nomad
$ go test ./client/...
Defensive patterns

Strategy: validation

Validate before calling

// Ensure a nomad binary exists where the helper looks before running tests
exe := "nomad"
if runtime.GOOS == "windows" { exe = "nomad.exe" }
wd, _ := os.Getwd()
if _, err := os.Stat(filepath.Join(wd, exe)); err != nil {
	if _, err := os.Stat(filepath.Join(wd, "bin", exe)); err != nil {
		return fmt.Errorf("build nomad first: run 'make dev'; missing %s", exe)
	}
}

Type guard

func isNomadBinaryMissing(err error) bool {
	return err != nil && strings.Contains(err.Error(), "Could not find Nomad executable") && !strings.Contains(err.Error(), ": ")
}

Try / catch

bin, err := discover.NomadExecutable()
if err != nil {
	t.Skipf("nomad binary not found; build it with 'make dev' (%v)", err)
}

Prevention

When it happens

Trigger: 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.

Common situations: 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).

Related errors


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/a74fcab44a9c216a. Report an issue: GitHub.