{"record":{"id":"5e73ca155ecc16a8","repo":"gastownhall/beads","slug":"bd-binary-not-found-in-path-w","errorCode":null,"errorMessage":"bd binary not found in PATH: %w","messagePattern":"bd binary not found in PATH: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/doctor/fix/common.go","lineNumber":53,"sourceCode":"\t\trealPath, err := filepath.EvalSymlinks(exe)\n\t\tif err == nil {\n\t\t\texe = realPath\n\t\t}\n\n\t\t// Check if we're running as a test binary - this prevents fork bombs\n\t\t// when tests call functions that execute bd subcommands\n\t\tbaseName := filepath.Base(exe)\n\t\tif strings.HasSuffix(baseName, \".test\") || strings.Contains(baseName, \".test.\") {\n\t\t\treturn \"\", ErrTestBinary\n\t\t}\n\n\t\treturn exe, nil\n\t}\n\n\t// Fallback to PATH lookup with validation\n\tbdPath, err := exec.LookPath(\"bd\")\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"bd binary not found in PATH: %w\", err)\n\t}\n\n\treturn bdPath, nil\n}\n\n// validateBeadsWorkspace ensures the path is a valid beads workspace before\n// attempting any fix operations. This prevents path traversal attacks.\nfunc validateBeadsWorkspace(path string) error {\n\t_, err := resolveWorkspaceBeadsDirs(path)\n\treturn err\n}\n\nfunc resolveWorkspaceBeadsDirs(path string) (workspaceBeadsDirs, error) {\n\tabsPath, err := filepath.Abs(path)\n\tif err != nil {\n\t\treturn workspaceBeadsDirs{}, fmt.Errorf(\"invalid path: %w\", err)\n\t}\n","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/doctor/fix/common.go#L35-L71","documentation":"getBdBinary locates the bd executable, preferring the current test binary and otherwise falling back to exec.LookPath(\"bd\"). If bd is not installed or not on PATH, this error wraps the LookPath failure and the calling doctor fix (e.g. GitHooks) cannot run.","triggerScenarios":"exec.LookPath(\"bd\") fails in getBdBinary (cmd/bd/doctor/fix/common.go:53) — bd not installed, not on PATH, or the current executable fallback did not apply (not running under `bd doctor` directly).","commonSituations":"bd installed via go install into ~/go/bin that is absent from PATH; using the library API outside the bd binary in tests or scripts; minimal containers/CI images without bd.","solutions":["Install bd or add its location to PATH: `export PATH=$PATH:$(go env GOPATH)/bin`.","Invoke the repair through the `bd doctor` command itself so the current-binary fallback resolves.","Verify with `which bd` / `command -v bd` in the same shell/environment that runs the fix.","In CI, install bd explicitly before running doctor-dependent steps."],"exampleFix":"// before\nbd doctor   // fails: bd binary not found in PATH\n// after\nexport PATH=\"$PATH:$(go env GOPATH)/bin\"\nbd doctor","handlingStrategy":"fallback","validationCode":"if _, err := exec.LookPath(\"bd\"); err != nil {\n\t// bd missing from PATH; install it or extend PATH before calling doctor fixes\n}","typeGuard":null,"tryCatchPattern":"if err := fix.GitHooks(ctx); err != nil && strings.Contains(err.Error(), \"bd binary not found\") {\n\t// fall back to explicit installation or set PATH before retrying\n\treturn fmt.Errorf(\"install bd or extend PATH: %w\", err)\n}","preventionTips":["Add GOPATH/bin to PATH after `go install` of bd","Invoke repairs via the `bd doctor` CLI so the current-binary fallback applies","Verify with `which bd` in the same environment as the caller","Install bd in CI images before running doctor-dependent steps"],"tags":["path","doctor","binary","environment"],"backgroundTag":"binary-not-found-in-path","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}