gastownhall/beads · error

cannot pin git executable path: %w

Error message

cannot pin git executable path: %w

What it means

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.

Source

Thrown at cmd/bd/worktree_cmd.go:644

		}
	}

	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 = resolved
	}

	env := scrubWorktreeRemovalGitEnv(os.Environ())
	env = append(
		env,
		"GIT_CONFIG_GLOBAL="+os.DevNull,
		"GIT_CONFIG_SYSTEM="+os.DevNull,
		"GIT_CONFIG_NOSYSTEM=1",
		"GIT_NO_REPLACE_OBJECTS=1",
		"GIT_OPTIONAL_LOCKS=0",
		"GIT_TEMPLATE_DIR=",
	)

	return &worktreeRemovalGit{
		executable: executable,

View on GitHub (pinned to 71377f2769)

Solutions

  1. cd to an existing directory (e.g. repo root) and rerun the command
  2. Confirm the CWD exists (`pwd`); restore/recreate it if deleted
  3. Run the bd command from the main repository root

Example fix

// before
cd /repos/deleted-wt && bd worktree remove other
// after
cd /repos/main && bd worktree remove other
Defensive patterns

Strategy: validation

Validate before calling

[ -d "$(pwd)" ] || { echo "cwd deleted; cd elsewhere first"; exit 1; }

Try / catch

if _, err := os.Getwd(); err != nil {
    return fmt.Errorf("cannot pin git path, cwd unresolvable: %w", err)
}

Prevention

When it happens

Trigger: `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.

Common situations: Terminal sitting in a removed worktree; container runtime deleting the workspace mid-run; stale NFS mount.

Related errors


AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30). Data as JSON: /api/errors/f82b687eb2d7b829. Report an issue: GitHub.