denoland/deno · error · AnyError

The `gh` CLI is required for installing from a branch. Insta

Error message

The `gh` CLI is required for installing from a branch.
Install it from https://cli.github.com/ and run `gh auth login`.

What it means

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.

Source

Thrown at cli/tools/upgrade.rs:834

  check_windows_access_denied_error(output_result, &output_exe_path)?;

  log::info!(
    "\nUpgraded successfully from PR #{} {}\n",
    colors::green(&pr_number.to_string()),
    colors::gray(&format!("({})", pr_title))
  );

  drop(temp_dir);
  Ok(())
}

fn upgrade_from_branch(
  branch: &str,
  upgrade_flags: &UpgradeFlags,
) -> Result<(), AnyError> {
  let gh_version = Command::new("gh").arg("--version").output();
  if gh_version.is_err() {
    bail!(
      "The `gh` CLI is required for installing from a branch.\n\
       Install it from https://cli.github.com/ and run `gh auth login`."
    );
  }

  log::info!(
    "{}",
    colors::gray(format!("Finding CI artifacts for branch '{branch}'..."))
  );

  let artifact_name = get_pr_artifact_name()?;
  let debug_artifact_name = get_pr_debug_artifact_name()?;

  let runs_output = Command::new("gh")
    .args([
      "run",
      "list",
      "--repo",

View on GitHub (pinned to 9ad36f7a2c)

Solutions

  1. Install the GitHub CLI from https://cli.github.com/ (`brew install gh` / `apt install gh` / winget).
  2. Run `gh auth login` so run lookups and artifact downloads are authorized.
  3. Confirm `gh --version` works in the same shell, then re-run the branch upgrade.
  4. If gh cannot be installed, build the branch from source instead.

Example fix

# before
deno upgrade --branch some-branch
# error: The `gh` CLI is required for installing from a branch.

# after
apt install gh && gh auth login
deno upgrade --branch some-branch
Defensive patterns

Strategy: validation

Validate before calling

command -v gh >/dev/null 2>&1 || { echo "install gh first"; exit 1; }
gh auth status >/dev/null 2>&1 || gh auth login
deno upgrade --branch <branch>

Try / catch

deno upgrade --branch b 2>err.log || { grep -q 'gh` CLI is required' err.log && install_gh; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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