{"record":{"id":"e99e7c58442655f0","repo":"hashicorp/nomad","slug":"specified-binary-is-invalid-v","errorCode":null,"errorMessage":"specified binary is invalid: %v","messagePattern":"specified binary is invalid: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/shared/executor/executor.go","lineNumber":783,"sourceCode":"\tif host, err := exec.LookPath(bin); err == nil {\n\t\treturn host, nil\n\t}\n\n\treturn \"\", fmt.Errorf(\"binary %q could not be found\", bin)\n}\n\n// makeExecutable makes the given file executable for root,group,others.\nfunc makeExecutable(binPath string) error {\n\tif runtime.GOOS == \"windows\" {\n\t\treturn nil\n\t}\n\n\tfi, err := os.Stat(binPath)\n\tif err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn fmt.Errorf(\"binary %q does not exist\", binPath)\n\t\t}\n\t\treturn fmt.Errorf(\"specified binary is invalid: %v\", err)\n\t}\n\n\t// If it is not executable, make it so.\n\tperm := fi.Mode().Perm()\n\treq := os.FileMode(0555)\n\tif perm&req != req {\n\t\tif err := os.Chmod(binPath, perm|req); err != nil {\n\t\t\treturn fmt.Errorf(\"error making %q executable: %s\", binPath, err)\n\t\t}\n\t}\n\treturn nil\n}\n\n// SupportedCaps returns a list of all supported capabilities in kernel.\nfunc SupportedCaps(allowNetRaw bool) []string {\n\tvar allCaps []string\n\tlist, _ := capability.ListSupported()\n\tfor _, cap := range list {","sourceCodeStart":765,"sourceCodeEnd":801,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/shared/executor/executor.go#L765-L801","documentation":"If os.Stat on the binary fails with an error other than NotExist, makeExecutable returns 'specified binary is invalid: %v' wrapping the underlying error (permission denied on a parent directory, path is a directory, I/O error, etc.). Raised from Launch, so the task cannot start until the path resolves to a stat-able regular file.","triggerScenarios":"Launching a task whose command path is a directory instead of a file; a parent directory lacks execute/search permission for the Nomad user; symlink loops or filesystem errors during stat.","commonSituations":"Config pointing at a directory (e.g. /usr/bin instead of /usr/bin/tool); restrictive permissions after deploying as another user; broken mount or network filesystem on the client.","solutions":["Read the wrapped inner error to identify the stat failure (EACCES, EISDIR, etc.)","Ensure the path points to a regular executable file, not a directory","Fix permissions on the binary and each parent directory so the Nomad client user can traverse them","Check mounts/links on the client if stat reports I/O or loop errors"],"exampleFix":"// before\nconfig { command = \"/opt/app/bin\" } // a directory\n// after\nconfig { command = \"/opt/app/bin/server\" }","handlingStrategy":"validation","validationCode":"fi, err := os.Stat(binPath)\nif err != nil {\n    return fmt.Errorf(\"cannot stat %s: %w\", binPath, err)\n}\nif fi.IsDir() {\n    return fmt.Errorf(\"%s is a directory, not an executable\", binPath)\n}","typeGuard":"func isRegularExecutable(path string) bool {\n    fi, err := os.Stat(path)\n    return err == nil && fi.Mode().IsRegular() && fi.Mode().Perm()&0111 != 0\n}","tryCatchPattern":"if err := client.Launch(...); err != nil {\n    if strings.Contains(err.Error(), \"specified binary is invalid\") {\n        return fmt.Errorf(\"check path/permissions on client: %w\", err)\n    }\n    return err\n}","preventionTips":["Ensure the command path points to a regular file, not a directory","Verify the Nomad client user can traverse all parent directories (o+x)","After deployments, re-stat the binary path as the Nomad user","Watch for broken symlinks or failed mounts on client hosts"],"tags":["filesystem","permissions","launch"],"backgroundTag":"binary-not-found-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"}