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

  1. Install the GitHub CLI: `brew install gh`, `apt install gh`, winget/choco on Windows, or download from https://cli.github.com/.
  2. Authenticate with `gh auth login` as the message instructs (lookup and artifact download require it).
  3. Verify with `gh --version` and `gh auth status` in the same shell, then re-run `deno upgrade --pr <n>`.
  4. 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

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


AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20). Data as JSON: /api/errors/2fb5eaa84cb5cb33. Report an issue: GitHub.