{"record":{"id":"3d9c84c3261ccf1f","repo":"gastownhall/beads","slug":"git-config-failed-w-output-s","errorCode":null,"errorMessage":"git config failed: %w (output: %s)","messagePattern":"git config failed: %w \\(output: (.+?)\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/hooks.go","lineNumber":1294,"sourceCode":"\treturn false\n}\n\nfunc configureSharedHooksPath() error {\n\t// Set git config core.hooksPath to an absolute path pointing to .beads-hooks.\n\t// Using an absolute path is critical for git worktrees (GH#2414):\n\t// git resolves relative core.hooksPath relative to the working tree root.\n\trepoRoot, _ := git.GetMainRepoRoot()\n\tif repoRoot == \"\" {\n\t\trepoRoot = git.GetRepoRoot()\n\t}\n\tif repoRoot == \"\" {\n\t\treturn fmt.Errorf(\"not in a git repository\")\n\t}\n\tabsHooksPath := filepath.Join(repoRoot, \".beads-hooks\")\n\tcmd := exec.Command(\"git\", \"config\", \"core.hooksPath\", absHooksPath)\n\tcmd.Dir = repoRoot\n\tif output, err := cmd.CombinedOutput(); err != nil {\n\t\treturn fmt.Errorf(\"git config failed: %w (output: %s)\", err, string(output))\n\t}\n\treturn nil\n}\n\nfunc configureBeadsHooksPath() error {\n\t// Set git config core.hooksPath to an absolute path pointing to .beads/hooks.\n\t// Using an absolute path is critical for git worktrees (GH#2414):\n\t// git resolves relative core.hooksPath relative to the working tree root,\n\t// so in a worktree \".beads/hooks\" would resolve to <worktree>/.beads/hooks/\n\t// which doesn't exist — the hooks live in the main repo's .beads/hooks/.\n\trepoRoot, _ := git.GetMainRepoRoot()\n\tif repoRoot == \"\" {\n\t\trepoRoot = git.GetRepoRoot()\n\t}\n\tif repoRoot == \"\" {\n\t\treturn fmt.Errorf(\"not in a git repository\")\n\t}\n\tabsHooksPath := filepath.Join(repoRoot, \".beads\", \"hooks\")","sourceCodeStart":1276,"sourceCodeEnd":1312,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/hooks.go#L1276-L1312","documentation":"configureSharedHooksPath sets git config core.hooksPath to <repoRoot>/.beads-hooks (absolute path, for worktree support). This error wraps a non-zero exit from `git config core.hooksPath`, including git's combined stderr/stdout output. It is thrown by `bd hooks install` when the underlying git command fails, e.g. a locked or corrupt config, insufficient permissions, or a multi-valued key.","triggerScenarios":"Running `bd hooks install` (installHooksWithOptions -> configureSharedHooksPath) in a repo where `git config core.hooksPath ...` exits non-zero: read-only or unwritable .git/config, corrupted git config file, git refusing because core.hooksPath has multiple values, or git binary missing/broken.","commonSituations":"CI containers running as a non-root user without write access to .git; repos with hand-edited or merge-conflicted .git/config; sandboxed environments where exec of git is blocked; a duplicated core.hooksPath entry from earlier tooling.","solutions":["Read the '(output: ...)' part of the message; it contains git's own diagnostic and usually names the exact problem.","Check write permission on the repo's .git/config for the user running bd.","Run `git config --get --all core.hooksPath`; if multiple values exist, remove duplicates with `git config --unset-all core.hooksPath`.","Verify git works: `git -C <repoRoot> config --list` — fix any parse errors it reports.","Retry `bd hooks install` after fixing."],"exampleFix":"// before (shell, diagnosing)\n$ bd hooks install\n// error: git config failed: exit status 1 (output: error: could not lock config file)\n// after\n$ sudo chown -R $(whoami) .git/config  # or fix permissions\n$ bd hooks install","handlingStrategy":"try-catch","validationCode":"if !command.Run() { return }\nout, err := exec.Command(\"git\", \"-C\", repoRoot, \"config\", \"--list\").CombinedOutput()\nif err != nil || !isWritable(filepath.Join(repoRoot, \".git\", \"config\")) {\n    return fmt.Errorf(\"git config not writable/parseable: %s\", out)\n}","typeGuard":null,"tryCatchPattern":"if _, err := configureSharedHooksPath(); err != nil {\n    var gitErr *exec.ExitError\n    if errors.As(err, &gitErr) {\n        log.Printf(\"git config failed; check .git/config permissions and duplicates: %v\", err)\n    }\n    return err\n}","preventionTips":["Run bd hooks install as a user with write access to .git/config","Check `git config --get-all core.hooksPath` for duplicates before installing","Keep .git/config free of hand-edited syntax errors"],"tags":["git","git-config","hooks-install","subprocess"],"backgroundTag":"git-config-write-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}