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.
- +0Prompt · +0Can we set up gh
- +0mAgent did · +0mChecked for gh/brew (neither installed), inspected OS and shell, found latest gh release tag via curl, and inspected PATH/.zshrc (which didn't exist).
- +0mFail · +0mDownloaded the macOS arm64 tar.gz release, but the download/extract failed.
- +0mAgent did · +0mSwitched 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.
- +0mAgent did · +0mChecked gh auth status (not logged in) and summarized the install, pointing to gh auth login as the next step.
- +2mPrompt · +2myes please
- +2mAgent did · +2mWalked through recommended gh auth login flow: GitHub.com, HTTPS, browser-based auth, plus verification commands.
- +10mPrompt · +10mnpm keeps asking me for sudo?
- +10mAgent did · +10mDiagnosed 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.
- +11mOutcome · +11mgh 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.