denoland/deno · error · AnyError
The `gh` CLI is required for installing from a PR. Install i
Error message
The `gh` CLI is required for installing from a PR. Install it from https://cli.github.com/ and run `gh auth login`.
What it means
`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.
Source
Thrown at cli/tools/upgrade.rs:616
};
// Prefer release builds, fall back to debug
Ok(format!("release-{os}-{arch}-deno"))
}
fn get_pr_debug_artifact_name() -> Result<String, AnyError> {
let release_name = get_pr_artifact_name()?;
Ok(release_name.replacen("release-", "debug-", 1))
}
fn upgrade_from_pr(
pr_number: u64,
upgrade_flags: &UpgradeFlags,
) -> Result<(), AnyError> {
// Check that `gh` CLI is available
let gh_version = Command::new("gh").arg("--version").output();
if gh_version.is_err() {
bail!(
"The `gh` CLI is required for installing from a PR.\n\
Install it from https://cli.github.com/ and run `gh auth login`."
);
}
log::info!("{}", colors::gray(format!("Looking up PR #{pr_number}...")));
// Verify the PR exists and get its title/state/branch
let pr_info = Command::new("gh")
.args([
"pr",
"view",
&pr_number.to_string(),
"--repo",
"denoland/deno",
"--json",
"title,state,headRefName,headRefOid",
"-q",View on GitHub (pinned to 9ad36f7a2c)
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.
Example fix
# before deno upgrade --pr 12345 # error: The `gh` CLI is required for installing from a PR. # after brew install gh # or: apt install gh gh auth login deno upgrade --pr 12345
Defensive patterns
Strategy: validation
Validate before calling
command -v gh >/dev/null 2>&1 || { echo "install gh first: https://cli.github.com/"; exit 1; }
gh auth status >/dev/null 2>&1 || { echo "run: gh auth login"; exit 1; }
deno upgrade --pr 12345 Try / catch
deno upgrade --pr 12345 2>err.log || { grep -q 'gh` CLI is required' err.log && install_gh_and_retry; } Prevention
- 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).
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- The `gh` CLI is required for installing from a branch. Insta
- Failed to find PR #{pr_number}: {stderr}
- Unsupported platform for PR builds: {}
- No CI runs found for PR #{pr_number}. The PR may not have be
- Could not find a "{}" artifact for PR #{pr_number}. Availabl
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/2fb5eaa84cb5cb33.
Report an issue: GitHub.