{"record":{"id":"904e1b1055e069e0","repo":"charmbracelet/crush","slug":"interpreter-q-not-found-in-path","errorCode":null,"errorMessage":"interpreter %q not found in PATH","messagePattern":"interpreter %q not found in PATH","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/shell/dispatch.go","lineNumber":240,"sourceCode":"//\n// The permissive fallback is what makes #!/bin/bash portable to Windows\n// boxes where Git for Windows puts bash.exe on PATH but there is no\n// /bin/bash on disk.\nfunc resolveInterpreter(path string) (string, error) {\n\t_, statErr := os.Stat(path)\n\tif statErr == nil {\n\t\treturn path, nil\n\t}\n\tif !errors.Is(statErr, fs.ErrNotExist) {\n\t\treturn \"\", statErr\n\t}\n\n\tbase := filepath.Base(path)\n\tif base == \"\" || base == path && !strings.ContainsAny(path, `/\\`) {\n\t\t// Already a bare name — just do a PATH lookup.\n\t\tresolved, err := exec.LookPath(path)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"interpreter %q not found in PATH\", path)\n\t\t}\n\t\treturn resolved, nil\n\t}\n\tresolved, err := exec.LookPath(base)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"interpreter %q not found and %q not in PATH\", path, base)\n\t}\n\tslog.Debug(\"Shebang interpreter not found; falling back to PATH\",\n\t\t\"requested\", path, \"resolved\", resolved)\n\treturn resolved, nil\n}\n\n// shebang captures the parsed `#!` line. interpreter is the program to\n// invoke; args is the list of extra arguments to pass before the script\n// path. The kernel's single-arg semantics (for literal paths and for env\n// without `-S`) is encoded by returning a single-element args slice\n// containing the un-tokenized remainder.\ntype shebang struct {","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/shell/dispatch.go#L222-L258","documentation":"resolveInterpreter failed to locate the shebang interpreter. When the shebang names a bare interpreter (no path separators, e.g. `#!/usr/bin/env bash` resolved to `bash`), the resolver falls back to exec.LookPath; if that lookup fails (ENOENT), the interpreter name is wrapped in this error. It means neither the literal path nor PATH contains a usable binary.","triggerScenarios":"A script with a shebang naming an interpreter that (a) contains no '/' so it is treated as a bare name, or (b) whose literal path does not exist (os.Stat returns fs.ErrNotExist) and whose basename is not on PATH. Raised by dispatchShebang whenever exec.LookPath returns an error for the bare name.","commonSituations":"Scripts authored for macOS/Linux run on minimal Windows containers where bash/zsh are not installed; typos in the shebang interpreter name; CI images stripped of the expected runtime (e.g. no python3); NixOS-style setups where /usr/bin/env shims are absent.","solutions":["Install the interpreter named in the shebang (or a package providing it) so it appears on PATH.","Rewrite the shebang to a literal path that exists on the target machine, e.g. #!/bin/sh instead of a missing interpreter.","On Windows, install Git for Windows and ensure bash.exe is on PATH so the permissive fallback can resolve it.","Verify PATH inside the execution environment (container, hook, CI job) — it may differ from your interactive shell PATH."],"exampleFix":"// before\n#!/usr/bin/env zsh\necho hi\n// after\n#!/bin/sh\necho hi","handlingStrategy":"validation","validationCode":"if _, err := exec.LookPath(\"bash\"); err != nil {\n    // interpreter missing; install or fix shebang before running the script\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    var notFound bool\n    if strings.Contains(err.Error(), \"not found in PATH\") {\n        notFound = true\n    }\n    _ = notFound\n}","preventionTips":["Check interpreter availability in setup scripts/containers before running user scripts.","Prefer `#!/usr/bin/env <name>` shebangs for portability.","Keep PATH consistent between dev and CI environments.","On Windows, ship Git for Windows and add bash to PATH."],"tags":["shell","shebang","path-lookup","interpreter"],"backgroundTag":"interpreter-not-found-in-path","analyzedSha":"7944b8e52225d8805e31eacbf7ef24856b0dfb7a","analyzedAt":"2026-08-29T12:48:59.079Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}