gastownhall/beads · error
worktree not found: %s
Error message
worktree not found: %s
What it means
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.
Source
Thrown at cmd/bd/worktree_cmd.go:629
}
// Consult git's worktree registry - match by name (basename) or path
// This handles worktrees created in subdirectories (e.g., .worktrees/foo)
// where the name shown in "bd worktree list" doesn't match a simple path
gitCmd := gitCmdInDir(ctx, repoRoot, "worktree", "list", "--porcelain")
output, err := gitCmd.CombinedOutput()
if err == nil {
worktrees := parseWorktreeList(string(output))
for _, wt := range worktrees {
if wt.Name == name || wt.Path == name {
if _, err := os.Stat(wt.Path); err == nil {
return wt.Path, nil
}
}
}
}
return "", fmt.Errorf("worktree not found: %s", name)
}
type worktreeRemovalGit struct {
executable string
env []string
}
func newWorktreeRemovalGit() (*worktreeRemovalGit, error) {
executable, err := exec.LookPath("git")
if err != nil {
return nil, fmt.Errorf("cannot find git executable: %w", err)
}
executable, err = filepath.Abs(executable)
if err != nil {
return nil, fmt.Errorf("cannot pin git executable path: %w", err)
}
if resolved, resolveErr := filepath.EvalSymlinks(executable); resolveErr == nil {
executable = resolvedView on GitHub (pinned to 71377f2769)
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
Example fix
// before bd worktree remove featur # typo // after bd worktree list bd worktree remove ../wt-feature
Defensive patterns
Strategy: validation
Validate before calling
bd worktree list | grep -Fx "$NAME" || echo "worktree '$NAME' not registered"
Try / catch
path, err := resolveWorktreePath(ctx, repoRoot, name)
if err != nil {
// fall back to interactive listing so the user picks a valid name
return fmt.Errorf("resolve %q: %w; run 'bd worktree list'", name, err)
} Prevention
- 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
When it happens
Trigger: `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).
Common situations: 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).
Related errors
- failed to inspect created worktree cleanliness: %w %s
- created worktree is dirty after checkout; refusing to contin
- failed to read git worktree registry: %w
- git worktree registry is empty
- server: NewDoltServer: failed to determine absolute path of
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/db7659d3e1797e27.
Report an issue: GitHub.