{"record":{"id":"dc48ff6df3463b5a","repo":"hashicorp/nomad","slug":"file-s-not-found-under-path","errorCode":null,"errorMessage":"file %s not found under path","messagePattern":"file (.+?) not found under path","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/shared/executor/executor_linux_cgo.go","lineNumber":1037,"sourceCode":"\t// root. Similar to the stdlib's exec.LookPath except:\n\t//   - uses a restricted lookup PATH rather than the agent process's PATH env var.\n\t//   - does not require that the file is already executable (this will be ensured\n\t//     by the caller)\n\t//   - does not prevent using relative path as added to exec.LookPath in go1.19\n\t//     (this gets fixed-up in the caller)\n\n\t// This is a fake PATH so that we're not using the agent's PATH\n\trestrictedPaths := []string{\"/usr/local/bin\", \"/usr/bin\", \"/bin\"}\n\n\tfor _, dir := range restrictedPaths {\n\t\tpathDir := filepath.Join(command.TaskDir, dir)\n\t\ttaskPath, hostPath, err = getPathInTaskDir(command.TaskDir, pathDir, bin)\n\t\tif err == nil {\n\t\t\treturn taskPath, hostPath, nil\n\t\t}\n\t}\n\n\treturn \"\", \"\", fmt.Errorf(\"file %s not found under path\", bin)\n}\n\n// getPathInTaskDir searches for the binary in the task directory and nested\n// search directory. It returns the absolute path rooted inside the container\n// and the absolute path on the host.\nfunc getPathInTaskDir(taskDir, searchDir, bin string) (string, string, error) {\n\n\thostPath := filepath.Join(searchDir, bin)\n\terr := filepathIsRegular(hostPath)\n\tif err != nil {\n\t\treturn \"\", \"\", err\n\t}\n\n\t// Find the path relative to the task directory\n\trel, err := filepath.Rel(taskDir, hostPath)\n\tif rel == \"\" || err != nil {\n\t\treturn \"\", \"\", fmt.Errorf(\n\t\t\t\"failed to determine relative path base=%q target=%q: %v\",","sourceCodeStart":1019,"sourceCodeEnd":1055,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/shared/executor/executor_linux_cgo.go#L1019-L1055","documentation":"lookupTaskBin exhausted all search directories (task dir plus configured lookup paths) without finding the bare binary name, so it fails with this message. It is the final 'binary not found anywhere in the task environment' error after PATH-style lookups fail.","triggerScenarios":"Launch with a binary name containing no '/' where neither the task dir nor any search path directories contain an executable file named bin — all getPathInTaskDir attempts returned errors.","commonSituations":"command = \"myapp\" but the artifact put it under a subdirectory; forgot to download the binary at all; binary name typo or wrong case; PATH_DIR task env (NOMAD_TASK_PATH-style search dirs) not including the artifact destination.","solutions":["Confirm where the binary actually is in the allocation dir and set command to that relative path","Fix artifact destination so the binary lands in a searched directory (task dir root)","Correct the binary name/case in the job spec","If using env-provided search dirs, ensure the required dir is included before launch"],"exampleFix":"// before\ncommand = \"app\"   # app is actually in local/bin/app\n// after\ncommand = \"local/bin/app\"","handlingStrategy":"validation","validationCode":"// binary name with no slash must exist in task dir or a search dir\nif !strings.Contains(task.Command, \"/\") {\n    if _, err := os.Stat(filepath.Join(taskDir, task.Command)); err != nil {\n        return fmt.Errorf(\"bare binary %q not in task dir\", task.Command)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"file \") && strings.Contains(err.Error(), \"not found under path\") {\n    return fmt.Errorf(\"binary lookup failed; verify artifacts and command name: %w\", err)\n}","preventionTips":["Match artifact destination to the command's relative path","Watch binary name casing; Linux paths are case-sensitive","Verify extraction produces a file, not a nested directory"],"tags":["executor","path-lookup","task-dir"],"backgroundTag":"binary-not-found-in-task-dir","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"}