gastownhall/beads · error
failed to configure git hooks path: %w
Error message
failed to configure git hooks path: %w
What it means
In beads-hooks mode, after writing hook files bd runs configureBeadsHooksPath to set git's local core.hooksPath to .beads/hooks. If that configuration step fails, installHooksWithOptions wraps it in this error — hooks were written, but git would not use them. The concrete git failure (and any command output) is in the wrapped error.
Source
Thrown at cmd/bd/hooks.go:982
newContent = injectHookSection(existingStr, section)
}
}
}
// Normalize line endings to LF
newContent = strings.ReplaceAll(newContent, "\r\n", "\n")
// Write hook file
// #nosec G306 -- git hooks must be executable for Git to run them
if err := os.WriteFile(hookPath, []byte(newContent), 0755); err != nil {
return fmt.Errorf("failed to write %s: %w", hookName, err)
}
}
// Configure git to use the hooks directory
if beadsHooks {
if err := configureBeadsHooksPath(); err != nil {
return fmt.Errorf("failed to configure git hooks path: %w", err)
}
} else if shared {
if err := configureSharedHooksPath(); err != nil {
return fmt.Errorf("failed to configure git hooks path: %w", err)
}
}
return nil
}
// preservePreexistingHooks copies non-beads hooks from the currently effective
// hooks directory into targetDir. This prevents hooks from a global
// core.hooksPath (or the default .git/hooks/) from being silently lost when
// beads sets a local core.hooksPath override.
func preservePreexistingHooks(targetDir string) {
// Get the hooks directory git would currently use (before we override it).
currentDir, err := git.GetGitHooksDir()
if err != nil {View on GitHub (pinned to 71377f2769)
Solutions
- Ensure you are inside a git repository (git rev-parse --is-inside-work-tree) and re-run
- Inspect the wrapped error for the underlying git message and fix accordingly
- Check .git/config is valid and writable; repair or re-clone if corrupt
- Set core.hooksPath manually: `git config core.hooksPath .beads/hooks`
Example fix
// before $ cd /not-a-repo && bd hooks install --beads-hooks failed to configure git hooks path: not in a git repository // after $ cd ~/myproject && bd hooks install --beads-hooks
Defensive patterns
Strategy: validation
Validate before calling
git rev-parse --is-inside-work-tree >/dev/null 2>&1 || echo 'not in a git repo; bd hooks path config will fail'
Try / catch
if err := installHooksWithOptions(names, false, false, false, true); err != nil { if strings.Contains(err.Error(), "configure git hooks path") { /* ensure in-repo and run: git config core.hooksPath .beads/hooks */ } } Prevention
- Only run --beads-hooks installs inside a git work tree
- Keep .git/config valid and writable
- Re-run hook install after re-cloning (git config is local)
When it happens
Trigger: installHooksWithOptions with beadsHooks=true calls configureBeadsHooksPath, which fails — usually because the current directory is not inside a git repository, or the underlying `git config core.hooksPath` command errors.
Common situations: Running `bd hooks install --beads-hooks` in a non-git directory; a bare/odd repo layout where git config cannot resolve; broken git installation or corrupt .git/config.
Related errors
- not in a git repository
- refusing to write secret key %q to git-tracked config file %
- server: NewDoltServer: doltBinExec is required
- server: NewDoltServer: rootDir is required
- server: NewDoltServer: configPath is required
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/1eb404f19db6a966.
Report an issue: GitHub.