macOS

Installation on macOS (bash/zsh)

Tested on macOS 12+ (Monterey, Ventura) in Terminal or iTerm2. Assumes a user account with Administrator (sudo) rights.


1. Prerequisites

  • macOS 12 or later

  • Homebrew (optional but recommended)

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  • Terminal: Built-in Terminal.app or iTerm2


2. Install Node.js (v22+) & npm

You can choose Homebrew or nvm for managing Node:

A. Homebrew

brew update
brew install node@22
# Ensure in your PATH:
echo 'export PATH="/opt/homebrew/opt/node@22/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

B. nvm (Node Version Manager)

  1. Install nvm:

    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
  2. Load nvm (add to ~/.zshrc or ~/.bash_profile):

    export NVM_DIR="$HOME/.nvm"
    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
  3. Install/use Node 22:

    nvm install 22
    nvm use 22
    node --version   # v22.x.x

C. Verify

node --version   # expect v22.x.x or higher
npm --version

3. Gatekeeper & Remote-Signed Files

Issue: “Cannot open ‘xyz’ because Apple cannot check it for malicious software.”

  1. Unblock downloaded files:

    xattr -dr com.apple.quarantine ~/Downloads/<file>
  2. Allow apps from anywhere (requires sudo):

    sudo spctl --master-disable

    ⚠️ Use sparingly; re-enable with sudo spctl --master-enable


4. Install the P0 CLI

Note: A standalone CLI is available—bundling NodeJS so you can skip installing Node/npm/nvm. macOS support is live; Download it from the GitHub releases page: https://github.com/p0-security/p0cli/releases

npm install -g @p0security/cli

If you hit EACCES or permissions errors:

sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
npm install -g @p0security/cli

Verify

p0 --version
p0 help

5. macOS Shell Setup

  • Ensure /usr/local/bin (or /opt/homebrew/bin) is in your PATH:

    echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.zshrc
    source ~/.zshrc
  • Enable command-completion:

    # in ~/.zshrc
    autoload -Uz compinit && compinit

8. Proxy & Corporate Networks

Issue: npm install stalling or p0 login failing behind proxy.

npm config set proxy http://proxy.company.com:8080
npm config set https-proxy http://proxy.company.com:8080

# Shell env vars:
export HTTP_PROXY="http://proxy.company.com:8080"
export HTTPS_PROXY="http://proxy.company.com:8080"

Add these to ~/.zshrc so they persist.


9. Common Troubleshooting

Symptom
Cause & Fix

zsh: command not found: p0

– Restart your terminal to reload PATH.– Check npm root -g and ensure p0 is there.

EACCES “permission denied”

– Fix ownership: sudo chown -R $(whoami) $(npm config get prefix)/*

AWS CLI not found in scripts

– Ensure Homebrew’s bin (/usr/local/bin or /opt/homebrew/bin) is in your PATH.

CLI hangs on p0 login

– Check $BROWSER env var: export BROWSER=open– If using Safari, allow pop-ups.

Last updated