Skip to content
PiinfraDevOps1 file · +2 −0

Install GitHub CLI and fix npm sudo prompts on macOS

Session from pi-extensions-sessions on Hugging Face by thomasmustier · MIT · condensed by Coders Talk

11msession
0interventions
GOAL

Install and configure the GitHub CLI (gh) on a Mac without Homebrew, then fix an unrelated npm permissions issue that was forcing sudo for global installs.

  1. Prompt · +0
    Can we set up gh
  2. Agent did · +0m
    Checked for gh/brew (neither installed), inspected OS and shell, found latest gh release tag via curl, and inspected PATH/.zshrc (which didn't exist).
  3. Fail · +0m
    Downloaded the macOS arm64 tar.gz release, but the download/extract failed.
  4. Agent did · +0m
    Switched to the zip archive instead, downloaded and installed the gh binary to ~/.local/bin, created a new .zshrc adding that dir to PATH, and verified gh --version works in an interactive shell.
  5. Agent did · +0m
    Checked gh auth status (not logged in) and summarized the install, pointing to gh auth login as the next step.
  6. Prompt · +2m
    yes please
  7. Agent did · +2m
    Walked through recommended gh auth login flow: GitHub.com, HTTPS, browser-based auth, plus verification commands.
  8. Prompt · +10m
    npm keeps asking me for sudo?
  9. Agent did · +10m
    Diagnosed that npm's global prefix was /usr/local, owned by root, causing sudo prompts. Set npm prefix to ~/.local and re-ran a test global install (pi-session-hud), which succeeded without sudo.
  10. Outcome · +11m
    gh v2.86.0 installed to ~/.local/bin with PATH fixed via .zshrc; npm global prefix moved to ~/.local, and a test package installed successfully without sudo.
VERDICT

Next time I'd just say upfront 'no Homebrew, install gh manually to ~/.local/bin' since the agent had to fumble through brew/apt checks and one failed tar.gz download before switching to the zip archive that actually worked. The real fix that mattered was catching that .zshrc didn't even exist and having the agent create it with the PATH export — after that gh just worked. The npm sudo issue was a nice bonus fix, straightforward once it checked ownership of /usr/local.

I tried this · 0

Discussion · 0

How Builds work