{"record":{"id":"db7659d3e1797e27","repo":"gastownhall/beads","slug":"worktree-not-found-s","errorCode":null,"errorMessage":"worktree not found: %s","messagePattern":"worktree not found: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/worktree_cmd.go","lineNumber":629,"sourceCode":"\t}\n\n\t// Consult git's worktree registry - match by name (basename) or path\n\t// This handles worktrees created in subdirectories (e.g., .worktrees/foo)\n\t// where the name shown in \"bd worktree list\" doesn't match a simple path\n\tgitCmd := gitCmdInDir(ctx, repoRoot, \"worktree\", \"list\", \"--porcelain\")\n\toutput, err := gitCmd.CombinedOutput()\n\tif err == nil {\n\t\tworktrees := parseWorktreeList(string(output))\n\t\tfor _, wt := range worktrees {\n\t\t\tif wt.Name == name || wt.Path == name {\n\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","sourceCodeStart":611,"sourceCodeEnd":647,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/worktree_cmd.go#L611-L647","documentation":"resolveWorktreePath maps a user-supplied worktree name (or path) to an actual directory: it checks the name as given, relative to cwd, relative to repo root, and finally git's own worktree registry. If none match (or the matched path no longer exists on disk), it returns this error naming the unresolved worktree.","triggerScenarios":"`bd worktree remove/info <name>` with a name that is neither a valid relative/absolute path, nor matches any registered worktree's Name/Path in `git worktree list --porcelain`; or the registered worktree directory was deleted from disk (os.Stat fails).","commonSituations":"Typo in the worktree name; worktree pruned with `git worktree prune` but still referenced; worktree directory deleted manually; passing a basename that differs from git's registered path (subdirectory worktrees like .worktrees/foo).","solutions":["Run `bd worktree list` (or `git worktree list`) to see the exact registered names/paths","Use the full registered path instead of the short name","If the directory is gone, run `git worktree prune` to clean stale registrations","Check for typos or trailing slashes in the name argument"],"exampleFix":"// before\nbd worktree remove featur   # typo\n// after\nbd worktree list\nbd worktree remove ../wt-feature","handlingStrategy":"validation","validationCode":"bd worktree list | grep -Fx \"$NAME\" || echo \"worktree '$NAME' not registered\"","typeGuard":null,"tryCatchPattern":"path, err := resolveWorktreePath(ctx, repoRoot, name)\nif err != nil {\n    // fall back to interactive listing so the user picks a valid name\n    return fmt.Errorf(\"resolve %q: %w; run 'bd worktree list'\", name, err)\n}","preventionTips":["Copy names exactly from `bd worktree list` / `git worktree list`","Use full registered paths for subdirectory worktrees (.worktrees/foo)","Run `git worktree prune` after manually deleting worktree directories"],"tags":["go","git","worktree","path-resolution"],"backgroundTag":"worktree-not-found","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}