{"record":{"id":"9deac57c3d3459d9","repo":"gastownhall/beads","slug":"cannot-find-git-executable-w","errorCode":null,"errorMessage":"cannot find git executable: %w","messagePattern":"cannot find git executable: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/worktree_cmd.go","lineNumber":640,"sourceCode":"\t\t\t\tif _, err := os.Stat(wt.Path); err == nil {\n\t\t\t\t\treturn wt.Path, nil\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn \"\", fmt.Errorf(\"worktree not found: %s\", name)\n}\n\ntype worktreeRemovalGit struct {\n\texecutable string\n\tenv        []string\n}\n\nfunc newWorktreeRemovalGit() (*worktreeRemovalGit, error) {\n\texecutable, err := exec.LookPath(\"git\")\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"cannot find git executable: %w\", err)\n\t}\n\texecutable, err = filepath.Abs(executable)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"cannot pin git executable path: %w\", err)\n\t}\n\tif resolved, resolveErr := filepath.EvalSymlinks(executable); resolveErr == nil {\n\t\texecutable = resolved\n\t}\n\n\tenv := scrubWorktreeRemovalGitEnv(os.Environ())\n\tenv = append(\n\t\tenv,\n\t\t\"GIT_CONFIG_GLOBAL=\"+os.DevNull,\n\t\t\"GIT_CONFIG_SYSTEM=\"+os.DevNull,\n\t\t\"GIT_CONFIG_NOSYSTEM=1\",\n\t\t\"GIT_NO_REPLACE_OBJECTS=1\",\n\t\t\"GIT_OPTIONAL_LOCKS=0\",\n\t\t\"GIT_TEMPLATE_DIR=\",","sourceCodeStart":622,"sourceCodeEnd":658,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/worktree_cmd.go#L622-L658","documentation":"Before performing worktree removal, bd pins down the git executable via exec.LookPath(\"git\") so subsequent subprocesses can't be repointed via PATH manipulation. If no `git` binary is found on PATH, this error is returned (wrapping exec.LookPath's exec.ErrNotFound).","triggerScenarios":"Any `bd worktree remove` (prepareWorktreeRemoval) or the env-scrubbing test when `git` is not present in any PATH directory — git not installed, or PATH stripped/broken in the executing environment.","commonSituations":"Minimal Docker images without git; CI jobs with sanitized PATH; cron/systemd environments lacking the user's PATH; broken PATH typo (e.g. PATH=/usr/loca/bin).","solutions":["Install git (apt-get install -y git / brew install git) and rerun","Fix PATH so the git binary's directory is included (check `which git`)","If git is in a nonstandard location, add its dir to PATH before invoking bd"],"exampleFix":"// before (docker: no git)\nbd worktree remove wt-x   # cannot find git executable\n// after\nRUN apt-get update && apt-get install -y git\nbd worktree remove wt-x","handlingStrategy":"validation","validationCode":"command -v git >/dev/null 2>&1 || { echo \"git not on PATH\"; exit 1; }","typeGuard":null,"tryCatchPattern":"exe, err := exec.LookPath(\"git\")\nif err != nil {\n    return fmt.Errorf(\"git required but not found: %w\", err)\n}","preventionTips":["Install git in CI images and minimal containers","Ensure PATH includes git's directory in cron/systemd environments","Verify with `which git` before running worktree removal"],"tags":["go","git","path","environment"],"backgroundTag":"missing-env-var","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}