{"record":{"id":"2fb5eaa84cb5cb33","repo":"denoland/deno","slug":"the-gh-cli-is-required-for-installing-from-a-pr","errorCode":null,"errorMessage":"The `gh` CLI is required for installing from a PR.\nInstall it from https://cli.github.com/ and run `gh auth login`.","messagePattern":"The `gh` CLI is required for installing from a PR\\.\nInstall it from https://cli\\.github\\.com/ and run `gh auth login`\\.","errorType":"exception","errorClass":"AnyError","httpStatus":null,"severity":"error","filePath":"cli/tools/upgrade.rs","lineNumber":616,"sourceCode":"  };\n\n  // Prefer release builds, fall back to debug\n  Ok(format!(\"release-{os}-{arch}-deno\"))\n}\n\nfn get_pr_debug_artifact_name() -> Result<String, AnyError> {\n  let release_name = get_pr_artifact_name()?;\n  Ok(release_name.replacen(\"release-\", \"debug-\", 1))\n}\n\nfn upgrade_from_pr(\n  pr_number: u64,\n  upgrade_flags: &UpgradeFlags,\n) -> Result<(), AnyError> {\n  // Check that `gh` CLI is available\n  let gh_version = Command::new(\"gh\").arg(\"--version\").output();\n  if gh_version.is_err() {\n    bail!(\n      \"The `gh` CLI is required for installing from a PR.\\n\\\n       Install it from https://cli.github.com/ and run `gh auth login`.\"\n    );\n  }\n\n  log::info!(\"{}\", colors::gray(format!(\"Looking up PR #{pr_number}...\")));\n\n  // Verify the PR exists and get its title/state/branch\n  let pr_info = Command::new(\"gh\")\n    .args([\n      \"pr\",\n      \"view\",\n      &pr_number.to_string(),\n      \"--repo\",\n      \"denoland/deno\",\n      \"--json\",\n      \"title,state,headRefName,headRefOid\",\n      \"-q\",","sourceCodeStart":598,"sourceCodeEnd":634,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/tools/upgrade.rs#L598-L634","documentation":"`deno upgrade --pr <n>` shells out to the GitHub CLI (`gh`) to look up the PR, list its CI runs, and download artifacts. Before doing anything it runs `gh --version`; if that command cannot be spawned (gh not installed or not on PATH), Deno bails with this message pointing at https://cli.github.com/. This is an environment prerequisite failure, not a Deno bug.","triggerScenarios":"Executing `deno upgrade --pr 12345` on a machine where the `gh` executable is absent from PATH, so `Command::new(\"gh\").arg(\"--version\").output()` returns Err at cli/tools/upgrade.rs:616.","commonSituations":"Fresh machines, minimal CI containers, or WSL/devcontainer images that never installed gh; PATH not forwarded into the shell running deno; docs/tutorials that assume gh is preinstalled.","solutions":["Install the GitHub CLI: `brew install gh`, `apt install gh`, winget/choco on Windows, or download from https://cli.github.com/.","Authenticate with `gh auth login` as the message instructs (lookup and artifact download require it).","Verify with `gh --version` and `gh auth status` in the same shell, then re-run `deno upgrade --pr <n>`.","If gh is installed but still not found, fix PATH so the deno process can spawn it."],"exampleFix":"# before\ndeno upgrade --pr 12345\n# error: The `gh` CLI is required for installing from a PR.\n\n# after\nbrew install gh   # or: apt install gh\ngh auth login\ndeno upgrade --pr 12345","handlingStrategy":"validation","validationCode":"command -v gh >/dev/null 2>&1 || { echo \"install gh first: https://cli.github.com/\"; exit 1; }\ngh auth status >/dev/null 2>&1 || { echo \"run: gh auth login\"; exit 1; }\ndeno upgrade --pr 12345","typeGuard":null,"tryCatchPattern":"deno upgrade --pr 12345 2>err.log || { grep -q 'gh` CLI is required' err.log && install_gh_and_retry; }","preventionTips":["Pre-install and authenticate gh in devcontainers/CI images that will use PR installs.","Add a `command -v gh` guard to scripts that wrap `deno upgrade --pr`.","Keep gh reasonably current (--json/-q flags are required)."],"tags":["upgrade","gh-cli","pr-build","external-tool","environment"],"backgroundTag":"missing-external-tool","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}