{"record":{"id":"9ed52b74a81ce95c","repo":"gastownhall/beads","slug":"gh-cli-not-found-install-from-https-cli-github-9ed52b","errorCode":null,"errorMessage":"gh CLI not found: install from https://cli.github.com","messagePattern":"gh CLI not found: install from https://cli\\.github\\.com","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/gate_discover.go","lineNumber":443,"sourceCode":"\toutput, err := cmd.Output()\n\tif err != nil {\n\t\treturn \"\"\n\t}\n\treturn strings.TrimSpace(string(output))\n}\n\n// queryGitHubRunsInRepo queries recent workflow runs from GitHub using gh\n// CLI, scoped to repo (\"\" means the current repository) and optionally\n// narrowed to a single workflow (workflow == \"\" queries all workflows). This\n// is the query path for `bd gate discover`'s branch/heuristic matching (SF1)\n// - distinct from queryGitHubRunsForWorkflowInRepo in gate.go, which filters\n// by a specific --workflow name for the direct await_id discovery used by\n// `bd gate check`. matchGatesToRuns only ever passes a non-empty workflow for\n// a foreign repo, to recover the visibility --limit would otherwise cost an\n// unfiltered cross-repo query (see matchGatesToRuns).\nfunc queryGitHubRunsInRepo(branch string, limit int, repo string, workflow string) ([]GHWorkflowRun, error) {\n\tif _, err := exec.LookPath(\"gh\"); err != nil {\n\t\treturn nil, fmt.Errorf(\"gh CLI not found: install from https://cli.github.com\")\n\t}\n\treturn queryGitHubRunsInRepoWithRunner(branch, limit, repo, workflow, runGHCommand)\n}\n\nfunc queryGitHubRunsInRepoWithRunner(branch string, limit int, repo string, workflow string, runGH ghCommandRunner) ([]GHWorkflowRun, error) {\n\targs := []string{\n\t\t\"run\", \"list\",\n\t\t\"--json\", \"databaseId,displayTitle,headBranch,headSha,name,status,conclusion,createdAt,updatedAt,workflowName,url\",\n\t\t\"--limit\", strconv.Itoa(limit),\n\t}\n\n\tif branch != \"\" {\n\t\targs = append(args, \"--branch\", branch)\n\t}\n\tif repo != \"\" {\n\t\targs = append(args, \"--repo\", repo)\n\t}\n\tif workflow != \"\" {","sourceCodeStart":425,"sourceCodeEnd":461,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/gate_discover.go#L425-L461","documentation":"queryGitHubRunsInRepo shells out to the GitHub `gh` CLI to list workflow runs. Before doing so it checks exec.LookPath(\"gh\"); if the binary is not on PATH it returns this fixed message directing the user to install the CLI. bd does not call the GitHub API itself for gate discovery, so gh is a hard requirement.","triggerScenarios":"Running `bd gate discover` (or `bd gate check` discovery paths) on a machine where the `gh` executable is not installed or is not on PATH (exec.LookPath fails).","commonSituations":"Fresh CI container or new laptop without gh installed; gh installed via a non-PATH location (e.g. manual download to ~/bin not on PATH); PATH differs between the user's shell and the environment running bd; Docker image missing the dependency.","solutions":["Install the GitHub CLI: see https://cli.github.com (e.g. `brew install gh` or `apt install gh`)","Verify `which gh` resolves and `gh --version` works in the same shell where bd runs","If gh is installed elsewhere, add its directory to PATH in the environment running bd","Authenticate once with `gh auth login` so subsequent run-list queries succeed"],"exampleFix":"// before\n$ bd gate discover\nError: gh CLI not found: install from https://cli.github.com\n// after\n$ brew install gh && gh auth login\n$ bd gate discover","handlingStrategy":"validation","validationCode":"if _, err := exec.LookPath(\"gh\"); err != nil {\n  return fmt.Errorf(\"gh CLI is required for gate discovery: install from https://cli.github.com\")\n}","typeGuard":null,"tryCatchPattern":"runs, err := queryGitHubRunsInRepo(branch, limit, repo, workflow)\nif err != nil && strings.Contains(err.Error(), \"gh CLI not found\") {\n  return fmt.Errorf(\"install gh first: https://cli.github.com, then `gh auth login`\")\n}","preventionTips":["Install gh in every environment (dev, CI image, container) that runs bd gate commands","Pin gh in CI Dockerfiles and verify with `gh --version` in the entrypoint","Run `gh auth login` (or set GH_TOKEN) as part of machine setup","Check `which gh` in shell startup when bd commands mysteriously fail"],"tags":["dependency","cli","github","environment"],"backgroundTag":"missing-dependency-binary","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}