{"record":{"id":"e50fefa920aa138c","repo":"gastownhall/beads","slug":"gh-cli-not-found-install-from-https-cli-github","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.go","lineNumber":945,"sourceCode":"\tif repo == \"\" {\n\t\treturn nil, nil\n\t}\n\tmetadata, err := json.Marshal(map[string]string{\"repo\": repo})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn metadata, nil\n}\n\n// queryGitHubRunsForWorkflow queries recent runs for a specific workflow using gh CLI.\n// Returns runs sorted newest-first (GitHub API default).\nfunc queryGitHubRunsForWorkflow(workflow string, limit int) ([]GHWorkflowRun, error) {\n\treturn queryGitHubRunsForWorkflowInRepo(workflow, limit, \"\")\n}\n\nfunc queryGitHubRunsForWorkflowInRepo(workflow string, limit int, repo 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 queryGitHubRunsForWorkflowInRepoWithRunner(workflow, limit, repo, runGHCommand)\n}\n\nfunc queryGitHubRunsForWorkflowInRepoWithRunner(workflow string, limit int, repo string, runGH ghCommandRunner) ([]GHWorkflowRun, error) {\n\targs := []string{\n\t\t\"run\", \"list\",\n\t\t\"--workflow\", workflow,\n\t\t\"--json\", \"databaseId,name,status,conclusion,createdAt,workflowName\",\n\t\t\"--limit\", fmt.Sprintf(\"%d\", limit),\n\t}\n\tif repo != \"\" {\n\t\targs = append(args, \"--repo\", repo)\n\t}\n\n\toutput, stderr, err := runGH(args...)\n\tif err != nil {\n\t\tif len(stderr) > 0 {","sourceCodeStart":927,"sourceCodeEnd":963,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/gate.go#L927-L963","documentation":"queryGitHubRunsForWorkflowInRepo shells out to the GitHub `gh` CLI; before doing so it runs exec.LookPath(\"gh\"). If no `gh` executable exists on PATH, gate checks that query workflow runs cannot proceed and this error is returned, pointing to the official install page.","triggerScenarios":"Any flow calling queryGitHubRunsForWorkflow / queryGitHubRunsForWorkflowInRepo (e.g. CI-gate checks matching beads gates to GH Actions runs) on a machine where gh is not installed or not on PATH.","commonSituations":"Fresh CI containers without gh installed; PATH differences between user shell and service accounts; gh installed via GUI but not symlinked into PATH; restricted environments (minimal Docker images).","solutions":["Install gh CLI (https://cli.github.com): e.g. `brew install gh` or apt/dnf per the docs.","Ensure the binary is on PATH for the user running bd: verify with `which gh`; adjust PATH in CI or service environments.","In containers, add gh installation to the image build instead of runtime.","Alternatively, provide a runner injection (ghCommandRunner) in tests/custom tooling so a real gh lookup is not required."],"exampleFix":"// before (CI step without gh)\n- run: bd doctor\n// after\n- run: |\n    type -p gh >/dev/null || (curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg && sudo apt install gh)\n- run: bd doctor","handlingStrategy":"fallback","validationCode":"if _, err := exec.LookPath(\"gh\"); err != nil {\n    // skip GH gate checks or print install guidance instead of failing hard\n    return nil // or fmt.Errorf(\"gh required for gate checks: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"runs, err := queryGitHubRunsForWorkflow(\"ci.yml\", 5)\nif err != nil {\n    if strings.Contains(err.Error(), \"gh CLI not found\") {\n        log.Printf(\"skipping GitHub gate checks: %v\", err)\n        return nil\n    }\n    return err\n}","preventionTips":["Install gh in CI images at build time (bake into Dockerfile).","Add a doctor-style preflight that checks `gh --version` before workflows needing it.","Ensure service users' PATH includes the gh install location (/usr/local/bin, /opt/homebrew/bin)."],"tags":["github","cli","environment"],"backgroundTag":"missing-binary-dependency","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}