{"record":{"id":"0a4684581471c00c","repo":"Hmbown/CodeWhale","slug":"the-github-pull-request-needs-the-gh-cli-on-path","errorCode":null,"errorMessage":"the GitHub pull request needs the gh CLI on PATH","messagePattern":"the GitHub pull request needs the gh CLI on PATH","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/dispatch_runner.rs","lineNumber":594,"sourceCode":"            args.first().unwrap_or(&\"\"),\n            sanitize_error(&String::from_utf8_lossy(&output.stderr))\n        );\n    }\n    Ok(String::from_utf8_lossy(&output.stdout).to_string())\n}\n\nfn open_pr_github(\n    slug: &str,\n    job: &CloudJob,\n    patch: &PatchReceipt,\n    title: &str,\n    body: &str,\n) -> Result<String> {\n    let body_dir = tempfile::tempdir().context(\"could not stage the PR body\")?;\n    let body_file = body_dir.path().join(\"body.md\");\n    std::fs::write(&body_file, body).context(\"could not write the PR body\")?;\n    let mut command = crate::dependencies::Gh::command()\n        .ok_or_else(|| anyhow!(\"the GitHub pull request needs the gh CLI on PATH\"))?;\n    command.args(gh_pr_create_argv(\n        slug,\n        &patch.base_branch,\n        &job.branch,\n        title,\n        &body_file.to_string_lossy(),\n    ));\n    let output = command\n        .output()\n        .context(\"failed to start gh for the pull request\")?;\n    if !output.status.success() {\n        bail!(\n            \"gh pr create failed: {}\",\n            sanitize_error(&String::from_utf8_lossy(&output.stderr))\n        );\n    }\n    let url = String::from_utf8_lossy(&output.stdout).trim().to_string();\n    if !url.starts_with(\"https://\") {","sourceCodeStart":576,"sourceCodeEnd":612,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/dispatch_runner.rs#L576-L612","documentation":"open_pr_github shells out to the external `gh` CLI to create the pull request; if crate::dependencies::Gh::command() returns None (gh not found on PATH) the PR step fails with this error, after the branch has already been pushed.","triggerScenarios":"open -> open_pr_github on a GitHub forge job while the gh binary is not installed or not on the PATH of the process running Codewhale.","commonSituations":"Running Codewhale in a container/systemd/CI environment where gh is not installed; a minimal shell PATH missing /usr/local/bin; gh installed only via an interactive-user version manager.","solutions":["Install the GitHub CLI (gh) and ensure it is on PATH, then run `gh auth login`.","Fix the PATH of the environment that launches Codewhale so the gh binary is discoverable.","As a fallback, create the PR manually from the pushed branch in the GitHub UI."],"exampleFix":"# before\n$ which gh   # not found\n# after\n$ brew install gh && gh auth status","handlingStrategy":"try-catch","validationCode":"if crate::dependencies::Gh::command().is_none() {\n    eprintln!(\"gh CLI is required for GitHub PRs; install it first\");\n}","typeGuard":null,"tryCatchPattern":"match open_pr_github(slug, job, patch, title, body) {\n    Err(e) if e.to_string().contains(\"needs the gh CLI on PATH\") => {\n        // skip PR step; branch already pushed, print manual PR URL\n    }\n    other => other?,\n}","preventionTips":["Install gh and run gh auth login before enabling cloud/forge jobs.","Ensure the service/user running Codewhale has gh on its PATH.","Check dependency presence at job startup, not at PR-open time."],"tags":["external-dependency","cli","pull-request","github"],"backgroundTag":"command-not-found","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}