gastownhall/beads · error
failed to init git in planning repo: %w
Error message
failed to init git in planning repo: %w
What it means
Wraps an error from running `git init` (exec.Command) inside the freshly created ~/.beads-planning directory. Thrown only on a newly created planning repo; it means the planning repository could not be initialized as a git repo, so beads cannot keep planning issues version-controlled there.
Source
Thrown at cmd/bd/init_contributor.go:320
}
}
homeDir, err := os.UserHomeDir()
if err != nil {
return fmt.Errorf("failed to get home directory: %w", err)
}
planningPath := filepath.Join(homeDir, ".beads-planning")
createdPlanning := false
if _, err := os.Stat(planningPath); os.IsNotExist(err) {
createdPlanning = true
if err := os.MkdirAll(planningPath, 0750); err != nil {
return fmt.Errorf("failed to create planning repo: %w", err)
}
gitInit := exec.Command("git", "init")
gitInit.Dir = planningPath
if err := gitInit.Run(); err != nil {
return fmt.Errorf("failed to init git in planning repo: %w", err)
}
planningBeadsDir := filepath.Join(planningPath, ".beads")
if err := os.MkdirAll(planningBeadsDir, 0750); err != nil {
return fmt.Errorf("failed to create .beads in planning repo: %w", err)
}
// Initialize the planning Dolt schema so commands like bd migrate-personal
// can open the store immediately without hitting an uninitialized DB.
// Non-fatal: no-CGO and server-mode builds skip this silently; the schema
// initializes on first use once a Dolt server is running for that path.
if planningStore, storeErr := newDoltStoreFromConfig(ctx, planningBeadsDir); storeErr == nil {
_ = planningStore.Close()
}
}
if err := store.SetConfig(ctx, "routing.mode", "auto"); err != nil {
return fmt.Errorf("failed to set routing.mode: %w", err)
}
if err := store.SetConfig(ctx, "routing.contributor", planningPath); err != nil {View on GitHub (pinned to 71377f2769)
Solutions
- Install git (apt-get install -y git / brew install git) and confirm `git --version` works
- Verify git is on PATH for the user running bd (echo $PATH; which git)
- Ensure ~/.beads-planning is writable and re-run bd init --contributor
- Check git's global config for errors that make any git invocation fail
Defensive patterns
Strategy: validation
Validate before calling
// Verify git is available before fork setup
if _, err := exec.LookPath("git"); err != nil {
return fmt.Errorf("git must be installed and on PATH: %w", err)
} Try / catch
if err := autoConfigureForkContributor(ctx, store, ...); err != nil {
if strings.Contains(err.Error(), "failed to init git in planning repo") {
fmt.Fprintln(os.Stderr, "Install git and ensure it is on PATH, then retry")
}
return err
} Prevention
- Install git in minimal images/containers
- Verify `git --version` works for the service user
- Keep PATH intact in cron/systemd contexts
When it happens
Trigger: exec.Command("git", "init").Run() fails with Dir=planningPath — typically the git binary is not installed or not on PATH, or the newly created directory is unwritable.
Common situations: Minimal containers/images without git installed; PATH missing /usr/bin in service contexts; git broken by a bad global config; security policies blocking exec.
Related errors
- dolt version probe failed
- failed to untrack redirect file: %w
- failed to untrack last-touched file: %w
- failed to untrack files: %w %s
- failed to set routing mode: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/e2bf0a68e66ebcc1.
Report an issue: GitHub.