{"record":{"id":"f82b687eb2d7b829","repo":"gastownhall/beads","slug":"cannot-pin-git-executable-path-w","errorCode":null,"errorMessage":"cannot pin git executable path: %w","messagePattern":"cannot pin git executable path: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/worktree_cmd.go","lineNumber":644,"sourceCode":"\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=\",\n\t)\n\n\treturn &worktreeRemovalGit{\n\t\texecutable: executable,","sourceCodeStart":626,"sourceCodeEnd":662,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/worktree_cmd.go#L626-L662","documentation":"After locating git on PATH, newWorktreeRemovalGit converts the result to an absolute path (filepath.Abs) to pin it against later PATH changes. filepath.Abs only fails if Getwd fails (e.g. deleted working directory), so this error indicates the process CWD is unresolvable at the moment of pinning.","triggerScenarios":"`bd worktree remove` invoked while the process working directory has been deleted or is otherwise unresolvable, so filepath.Abs on the git path cannot be computed.","commonSituations":"Terminal sitting in a removed worktree; container runtime deleting the workspace mid-run; stale NFS mount.","solutions":["cd to an existing directory (e.g. repo root) and rerun the command","Confirm the CWD exists (`pwd`); restore/recreate it if deleted","Run the bd command from the main repository root"],"exampleFix":"// before\ncd /repos/deleted-wt && bd worktree remove other\n// after\ncd /repos/main && bd worktree remove other","handlingStrategy":"validation","validationCode":"[ -d \"$(pwd)\" ] || { echo \"cwd deleted; cd elsewhere first\"; exit 1; }","typeGuard":null,"tryCatchPattern":"if _, err := os.Getwd(); err != nil {\n    return fmt.Errorf(\"cannot pin git path, cwd unresolvable: %w\", err)\n}","preventionTips":["Run bd from the main repo root, not transient directories","Recreate deleted worktrees before executing commands from them","Avoid removing the directory a process is cd'd into"],"tags":["go","filesystem","cwd","git"],"backgroundTag":"current-directory-unresolvable","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}