gastownhall/beads · warning

resolve path: %w

Error message

resolve path: %w

What it means

PlanHookMigration first converts the user-supplied path to an absolute path with filepath.Abs before inspecting git hooks. filepath.Abs fails only when obtaining the current working directory fails, and the failure is wrapped as 'resolve path'. This is one of the rarest Go path errors because it depends on the process cwd, not the argument.

Source

Thrown at cmd/bd/doctor/hooks_migration.go:60

}

// HookMigrationPlan summarizes migration state for all managed hooks.
type HookMigrationPlan struct {
	Path                string                  `json:"path"`
	RepoRoot            string                  `json:"repo_root,omitempty"`
	HooksDir            string                  `json:"hooks_dir,omitempty"`
	IsGitRepo           bool                    `json:"is_git_repo"`
	Hooks               []HookMigrationHookPlan `json:"hooks"`
	TotalHooks          int                     `json:"total_hooks"`
	NeedsMigrationCount int                     `json:"needs_migration_count"`
	BrokenMarkerCount   int                     `json:"broken_marker_count"`
}

// PlanHookMigration builds a read-only migration plan for git hooks.
func PlanHookMigration(path string) (HookMigrationPlan, error) {
	absPath, err := filepath.Abs(path)
	if err != nil {
		return HookMigrationPlan{}, fmt.Errorf("resolve path: %w", err)
	}

	plan := HookMigrationPlan{
		Path:       absPath,
		TotalHooks: len(managedHookNames),
		Hooks:      make([]HookMigrationHookPlan, 0, len(managedHookNames)),
	}

	repoRoot, hooksDir, err := resolveGitHooksDir(absPath)
	if err != nil {
		var exitErr *exec.ExitError
		if errors.As(err, &exitErr) {
			// Not a git repository (or no git metadata reachable from path).
			return plan, nil
		}
		return HookMigrationPlan{}, err
	}

View on GitHub (pinned to 71377f2769)

Solutions

  1. cd to a valid existing directory (e.g. the repo root) and re-run the command.
  2. Open a fresh shell session if your current directory was deleted or renamed.
  3. Pass an absolute path for the repo so the resolution is less dependent on cwd.
  4. In scripts, verify the working directory exists before invoking bd (test -d "$PWD").

Example fix

// before
$ cd /tmp/some-deleted-dir
$ bd doctor hooks --plan .
Error: resolve path: getwd: no such file or directory
// after
$ cd /path/to/repo
$ bd doctor hooks --plan .
Defensive patterns

Strategy: validation

Validate before calling

if _, err := os.Getwd(); err != nil {
    return fmt.Errorf("current working directory is unusable: %w", err)
}
if _, err := os.Stat(path); err != nil {
    return fmt.Errorf("target path %q does not exist: %w", path, err)
}

Try / catch

plan, err := doctor.PlanHookMigration(path)
if err != nil && strings.HasPrefix(err.Error(), "resolve path:") {
    // recover by cd'ing to a valid directory or passing an absolute path
    return retryWithAbsPath
}

Prevention

When it happens

Trigger: filepath.Abs(path) returns an error, which happens when the process's current working directory has been deleted or cannot be stat'd (os.Getwd fails).

Common situations: Running bd from a directory that was deleted or replaced while the shell sat in it; a deleted worktree; containers/k8s exec sessions whose cwd vanished; running via a symlinked cwd that no longer resolves.

Related errors


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