{"record":{"id":"725f68c3c135868c","repo":"hashicorp/nomad","slug":"file-s-not-found-under-path-s","errorCode":null,"errorMessage":"file %s not found under path %s","messagePattern":"file (.+?) not found under path (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/shared/executor/executor_linux_cgo.go","lineNumber":1015,"sourceCode":"\t}\n\n\t// Check at the root of the task's directory\n\ttaskPath, hostPath, err = getPathInTaskDir(command.TaskDir, command.TaskDir, bin)\n\tif err == nil {\n\t\treturn taskPath, hostPath, nil\n\t}\n\n\t// Check in our mounts\n\tfor _, mount := range command.Mounts {\n\t\ttaskPath, hostPath, err = getPathInMount(mount.HostPath, mount.TaskPath, bin)\n\t\tif err == nil {\n\t\t\treturn taskPath, hostPath, nil\n\t\t}\n\t}\n\n\t// If there's a / in the binary's path, we can't fallback to a PATH search\n\tif strings.Contains(bin, \"/\") {\n\t\treturn \"\", \"\", fmt.Errorf(\"file %s not found under path %s\", bin, taskDir)\n\t}\n\n\t// look for a file using a PATH-style lookup inside the directory\n\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","sourceCodeStart":997,"sourceCodeEnd":1033,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/shared/executor/executor_linux_cgo.go#L997-L1033","documentation":"lookupTaskBin resolves a task's binary to a path inside the task directory. When the binary string contains a '/' it cannot fall back to a PATH-style search, so if it was not already found under the task dir this error is thrown. It means the explicitly-pathed binary does not exist inside the task's filesystem root.","triggerScenarios":"Launch is called with a command whose binary includes a '/' (e.g. ./bin/app or /opt/tool) and lookupTaskBin cannot find that file in the task dir or mount paths before hitting this check.","commonSituations":"Job specifies bin = \"./myapp\" but the artifact was not downloaded/extracted into the task dir; binary placed under chroot-unfriendly absolute path; driver template or env misconfiguration producing wrong path; case-sensitivity mismatch on the path.","solutions":["Verify the file exists at the given relative path inside the task dir (check allocation dir on the client)","Fix the bin path in the job spec or ensure artifacts/templates produce the file before launch","Use a bare binary name (no '/') so the PATH-style lookup in task dir runs","Check artifact destination and unzipping settings so the binary lands where bin points"],"exampleFix":"// before (job)\ncommand = \"./bin/missing-app\"\n// after\nartifact { source = \"...\"; destination = \"local/bin\" }\ncommand = \"local/bin/app\"","handlingStrategy":"validation","validationCode":"bin := task.Command\nif strings.Contains(bin, \"/\") {\n    p := filepath.Join(allocDir, bin)\n    if _, err := os.Stat(p); err != nil {\n        return fmt.Errorf(\"binary %s not present in task dir before launch\", bin)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"not found under path\") {\n    return fmt.Errorf(\"check command path/artifacts: %w\", err)\n}","preventionTips":["Ensure artifacts download and extract before Launch runs","Use paths relative to the task dir for the command","Spot-check the allocation directory layout when changing command paths"],"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"}