{"record":{"id":"1cc066b298a99ec3","repo":"gastownhall/beads","slug":"failed-to-install-hooks-w","errorCode":null,"errorMessage":"failed to install hooks: %w","messagePattern":"failed to install hooks: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/doctor/fix/hooks.go","lineNumber":634,"sourceCode":"\t}\n\n\t// Build command arguments\n\t// Use --force to cleanly replace outdated hooks without creating backups (GH#1466)\n\targs := []string{\"hooks\", \"install\", \"--force\"}\n\n\t// If external hook managers detected, use --chain to preserve them\n\tif len(externalManagers) > 0 {\n\t\targs = append(args, \"--chain\")\n\t}\n\n\t// Run bd hooks install\n\tcmd := newBdCmd(bdBinary, args...)\n\tcmd.Dir = path // Set working directory without changing process dir\n\tcmd.Stdout = os.Stdout\n\tcmd.Stderr = os.Stderr\n\n\tif err := cmd.Run(); err != nil {\n\t\treturn fmt.Errorf(\"failed to install hooks: %w\", err)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":616,"sourceCodeEnd":639,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/doctor/fix/hooks.go#L616-L639","documentation":"GitHooks shells out to `bd hooks install` (newBdCmd with cmd.Dir set to the target path) and wraps any non-zero exit as \"failed to install hooks: %w\". The child's stdout/stderr are already streamed to the terminal, so the wrapped cause plus that output tells you exactly why the hook install failed.","triggerScenarios":"Running the hooks fix when the `bd hooks install` subprocess exits non-zero: unknown or invalid hook flags/path, the bd binary found is broken or an incompatible version, permission denied writing .git/hooks, or the target stopped being a valid repo between the git check and install.","commonSituations":"Outdated bd binary on PATH that lacks the hooks subcommand; read-only or root-owned .git/hooks directory; hook conflicts with husky/lefthook/other managers refusing to overwrite; interrupted git repo state.","solutions":["Read the streamed stderr from the `bd hooks install` output above the error and fix that specific cause","Run `bd hooks install` manually inside the repo to reproduce and see the raw failure","Check write permission on .git/hooks and resolve external hook-manager conflicts (husky/lefthook) before installing"],"exampleFix":"// before\n$ bd doctor  # failed to install hooks: exit status 1 (permission denied writing .git/hooks/pre-commit)\n// after\n$ sudo chown -R $(whoami) .git/hooks\n$ bd hooks install","handlingStrategy":"try-catch","validationCode":"// Verify the bd binary supports the hooks subcommand and hooks dir is writable\nif err := exec.Command(bdBinary, \"hooks\", \"--help\").Run(); err != nil {\n\treturn fmt.Errorf(\"bd binary %s lacks hooks support\", bdBinary)\n}\nif f, err := os.OpenFile(filepath.Join(path, \".git\", \"hooks\", \".probe\"), os.O_CREATE|os.O_WRONLY, 0o755); err != nil {\n\treturn fmt.Errorf(\".git/hooks not writable: %w\", err)\n} else { f.Close(); os.Remove(filepath.Join(path, \".git\", \"hooks\", \".probe\")) }","typeGuard":null,"tryCatchPattern":"if err := fix.GitHooks(path, bdBinary); err != nil {\n\tvar exitErr *exec.ExitError\n\tif errors.As(err, &exitErr) {\n\t\tlog.Printf(\"bd hooks install exited %d; see streamed output above for the cause\", exitErr.ExitCode())\n\t}\n\treturn err\n}","preventionTips":["Keep the bd binary on PATH up to date with the repo's expected version","Check .git/hooks write permissions before installing","Resolve external hook manager conflicts (husky/lefthook) ahead of `bd hooks install`","Run `bd hooks install` manually once to surface raw errors"],"tags":["git","hooks","subprocess","doctor"],"backgroundTag":"hook-install-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}