{"record":{"id":"1eb404f19db6a966","repo":"gastownhall/beads","slug":"failed-to-configure-git-hooks-path-w","errorCode":null,"errorMessage":"failed to configure git hooks path: %w","messagePattern":"failed to configure git hooks path: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/hooks.go","lineNumber":982,"sourceCode":"\t\t\t\t\tnewContent = injectHookSection(existingStr, section)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Normalize line endings to LF\n\t\tnewContent = strings.ReplaceAll(newContent, \"\\r\\n\", \"\\n\")\n\n\t\t// Write hook file\n\t\t// #nosec G306 -- git hooks must be executable for Git to run them\n\t\tif err := os.WriteFile(hookPath, []byte(newContent), 0755); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to write %s: %w\", hookName, err)\n\t\t}\n\t}\n\n\t// Configure git to use the hooks directory\n\tif beadsHooks {\n\t\tif err := configureBeadsHooksPath(); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to configure git hooks path: %w\", err)\n\t\t}\n\t} else if shared {\n\t\tif err := configureSharedHooksPath(); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to configure git hooks path: %w\", err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// preservePreexistingHooks copies non-beads hooks from the currently effective\n// hooks directory into targetDir. This prevents hooks from a global\n// core.hooksPath (or the default .git/hooks/) from being silently lost when\n// beads sets a local core.hooksPath override.\nfunc preservePreexistingHooks(targetDir string) {\n\t// Get the hooks directory git would currently use (before we override it).\n\tcurrentDir, err := git.GetGitHooksDir()\n\tif err != nil {","sourceCodeStart":964,"sourceCodeEnd":1000,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/hooks.go#L964-L1000","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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`"],"exampleFix":"// before\n$ cd /not-a-repo && bd hooks install --beads-hooks\nfailed to configure git hooks path: not in a git repository\n// after\n$ cd ~/myproject && bd hooks install --beads-hooks","handlingStrategy":"validation","validationCode":"git rev-parse --is-inside-work-tree >/dev/null 2>&1 || echo 'not in a git repo; bd hooks path config will fail'","typeGuard":null,"tryCatchPattern":"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 */ } }","preventionTips":["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)"],"tags":["git","config","hooks-path"],"backgroundTag":"git-hooks-path-config-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}