{"record":{"id":"9aa592d5a06daa75","repo":"gastownhall/beads","slug":"s-9aa592","errorCode":null,"errorMessage":"%s","messagePattern":"%s","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/hooks.go","lineNumber":875,"sourceCode":"// containing it. Errors (not a repo, path inside .git/, no work tree) count\n// as untracked — the guard only blocks writes it can prove are unsafe.\nfunc isGitTrackedFile(path string) bool {\n\tdir := filepath.Dir(path)\n\tbase := filepath.Base(path)\n\t// #nosec G204 G702 - fixed \"git\" command; dir/base come from the hooks\n\t// directory bd itself resolved, not user input\n\tcmd := exec.Command(\"git\", \"-C\", dir, \"ls-files\", \"--error-unmatch\", \"--\", base)\n\treturn cmd.Run() == nil\n}\n\n//nolint:unparam // force and chain kept for CLI flag compatibility; section markers make them no-ops\nfunc installHooksWithOptions(hookNames []string, force bool, shared bool, chain bool, beadsHooks bool) error {\n\tvar hooksDir string\n\tif beadsHooks {\n\t\t// Use .beads/hooks/ directory (preferred for Dolt backend)\n\t\tbeadsDir := beads.FindBeadsDir()\n\t\tif beadsDir == \"\" {\n\t\t\treturn fmt.Errorf(\"%s\", activeWorkspaceNotFoundError())\n\t\t}\n\t\thooksDir = filepath.Join(beadsDir, \"hooks\")\n\t} else if shared {\n\t\t// Use versioned directory for shared hooks\n\t\tif mainRoot, err := git.GetMainRepoRoot(); err == nil && mainRoot != \"\" {\n\t\t\thooksDir = filepath.Join(mainRoot, \".beads-hooks\")\n\t\t} else {\n\t\t\thooksDir = \".beads-hooks\"\n\t\t}\n\t} else {\n\t\t// Use common git directory for hooks (shared across worktrees)\n\t\tvar err error\n\t\thooksDir, err = git.GetGitHooksDir()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n","sourceCodeStart":857,"sourceCodeEnd":893,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/hooks.go#L857-L893","documentation":"installHooksWithOptions wraps the activeWorkspaceNotFoundError message when `bd hooks install --beads-hooks` (beadsHooks mode) cannot locate a bd workspace. beads.FindBeadsDir() returns empty when no .beads directory / bd workspace exists in or above the current directory, so hook installation cannot proceed.","triggerScenarios":"Running bd hook installation with the beads hooks mode in a directory with no .beads workspace — e.g. outside a repo, before `bd init`, or in a subdirectory excluded from the workspace search.","commonSituations":"Running `bd hooks install` in a fresh clone before `bd init`; running from a non-repo temp directory; BEADS_DIR mis-set or the .beads dir deleted.","solutions":["Run `bd init` in the repository root to create the .beads workspace, then install hooks","cd to the repository root (or a directory containing .beads) and re-run the install","Read the wrapped message (the activeWorkspaceNotFoundError text) — it names the exact search root that failed"],"exampleFix":"// before\n$ cd /tmp && bd hooks install --beads-hooks\nerror: no bd workspace found...\n// after\n$ cd ~/myproject && bd init && bd hooks install --beads-hooks","handlingStrategy":"validation","validationCode":"if [ -z \"$(bd workspace 2>/dev/null)\" ] && [ ! -d .beads ]; then echo 'run bd init first'; fi","typeGuard":null,"tryCatchPattern":"if err := installHooksWithOptions(names, false, false, false, true); err != nil { if strings.Contains(err.Error(), \"workspace\") { return fmt.Errorf(\"run `bd init` before installing beads hooks: %w\", err) }; return err }","preventionTips":["Run `bd init` before installing hooks in a new clone","Run hook installation from the repository root","Verify the .beads directory exists before scripted hook installs"],"tags":["workspace","hooks","missing-init"],"backgroundTag":"workspace-not-found","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}