nikivdev/code · error
`gh` is installed but not working
Error message
`gh` is installed but not working
What it means
ensure_gh_available runs `gh --version` (with output discarded) before syncing secrets. If gh is found but exits non-zero, the tool concludes the GitHub CLI is broken and bails. It is distinct from the 'gh not installed' case, which fails earlier with a different error.
Source
Thrown at src/release_signing.rs:225
ensure_gh_available()?;
for key in SIGNING_KEYS {
let value = vars.get(key).expect("checked above");
gh_secret_set(opts.repo.as_deref(), key, value)?;
println!("✓ Set GitHub secret: {}", key);
}
Ok(())
}
fn ensure_gh_available() -> Result<()> {
let status = Command::new("gh")
.args(["--version"])
.stdout(Stdio::null())
.stderr(Stdio::null())
.status()
.context("failed to run `gh` (GitHub CLI)")?;
if !status.success() {
bail!("`gh` is installed but not working");
}
Ok(())
}
fn gh_secret_set(repo: Option<&str>, name: &str, value: &str) -> Result<()> {
let mut cmd = Command::new("gh");
cmd.args(["secret", "set", name]);
if let Some(repo) = repo {
cmd.args(["--repo", repo]);
}
// Avoid passing secrets via argv (ps); `gh secret set` reads from stdin when --body is omitted.
let mut child = cmd
.stdin(Stdio::piped())
.stdout(Stdio::null())
.spawn()
.with_context(|| format!("failed to spawn `gh secret set {}`", name))?;
View on GitHub (pinned to a747e741ae)
Solutions
- Reinstall/upgrade gh (`brew upgrade gh` or your package manager's equivalent)
- Run `gh --version` and `gh auth status` manually to see the failure
- Check PATH for shadowing/broken `gh` binaries (`which -a gh`)
Defensive patterns
Strategy: validation
Validate before calling
const { status } = spawnSync("gh", ["--version"], { stdio: "ignore" });
if (status !== 0) throw new Error("gh is broken; reinstall before syncing signing secrets"); Try / catch
try {
run(["f", "release", "signing", "sync"]);
} catch (e) {
if (String(e).includes("not working") || String(e).includes("failed to run `gh`")) {
console.error("Reinstall the GitHub CLI (brew upgrade gh) and run `gh auth login`.");
} else throw e;
} Prevention
- Install gh via a maintained package manager and keep it updated
- Run `gh --version` and `gh auth status` as pipeline preflight checks
- Avoid shadowing `gh` with broken binaries on PATH
When it happens
Trigger: `gh --version` returns a non-zero exit status during `f release signing sync`.
Common situations: Broken or partially upgraded gh binary; incompatible gh installed via mismatched package manager; permissions/exec issues; corrupted PATH entry pointing to a stub.
Related errors
- `gh secret set {}` failed
- native session bridge warm command failed with status {}
- pbcopy exited with status {}
- clipboard command exited with status {}
- AI task '{}' failed with status {}
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/00d7f49f76099bcb.
Report an issue: GitHub.