{"record":{"id":"2e9581ce26b81fa2","repo":"denoland/deno","slug":"the-gh-cli-is-required-for-installing-from-a-bra","errorCode":null,"errorMessage":"The `gh` CLI is required for installing from a branch.\nInstall it from https://cli.github.com/ and run `gh auth login`.","messagePattern":"The `gh` CLI is required for installing from a branch\\.\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":834,"sourceCode":"  check_windows_access_denied_error(output_result, &output_exe_path)?;\n\n  log::info!(\n    \"\\nUpgraded successfully from PR #{} {}\\n\",\n    colors::green(&pr_number.to_string()),\n    colors::gray(&format!(\"({})\", pr_title))\n  );\n\n  drop(temp_dir);\n  Ok(())\n}\n\nfn upgrade_from_branch(\n  branch: &str,\n  upgrade_flags: &UpgradeFlags,\n) -> Result<(), AnyError> {\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 branch.\\n\\\n       Install it from https://cli.github.com/ and run `gh auth login`.\"\n    );\n  }\n\n  log::info!(\n    \"{}\",\n    colors::gray(format!(\"Finding CI artifacts for branch '{branch}'...\"))\n  );\n\n  let artifact_name = get_pr_artifact_name()?;\n  let debug_artifact_name = get_pr_debug_artifact_name()?;\n\n  let runs_output = Command::new(\"gh\")\n    .args([\n      \"run\",\n      \"list\",\n      \"--repo\",","sourceCodeStart":816,"sourceCodeEnd":852,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/tools/upgrade.rs#L816-L852","documentation":"The branch-based upgrade flow (`deno upgrade --branch` / from-branch path) also drives GitHub via the `gh` CLI to find CI runs and download artifacts. It first probes `gh --version`; if spawning gh fails, Deno bails with this prerequisite error. Identical in nature to the PR-flow variant, but for branch installs.","triggerScenarios":"Running the from-branch upgrade on a machine without the `gh` executable on PATH, so `Command::new(\"gh\").arg(\"--version\").output()` errors at cli/tools/upgrade.rs:834.","commonSituations":"Same as the PR case: fresh machines, minimal containers, WSL images, or PATH issues where gh is present but not resolvable by the deno process.","solutions":["Install the GitHub CLI from https://cli.github.com/ (`brew install gh` / `apt install gh` / winget).","Run `gh auth login` so run lookups and artifact downloads are authorized.","Confirm `gh --version` works in the same shell, then re-run the branch upgrade.","If gh cannot be installed, build the branch from source instead."],"exampleFix":"# before\ndeno upgrade --branch some-branch\n# error: The `gh` CLI is required for installing from a branch.\n\n# after\napt install gh && gh auth login\ndeno upgrade --branch some-branch","handlingStrategy":"validation","validationCode":"command -v gh >/dev/null 2>&1 || { echo \"install gh first\"; exit 1; }\ngh auth status >/dev/null 2>&1 || gh auth login\ndeno upgrade --branch <branch>","typeGuard":null,"tryCatchPattern":"deno upgrade --branch b 2>err.log || { grep -q 'gh` CLI is required' err.log && install_gh; }","preventionTips":["Include gh in base images used for branch installs.","Guard scripts with `command -v gh` before calling branch upgrades.","Authenticate gh once per environment (`gh auth login`)."],"tags":["upgrade","gh-cli","branch-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"}