> For the complete documentation index, see [llms.txt](https://docs.p0.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.p0.dev/p0-cli/installing-p0-cli/macos.md).

# macOS

**Installation on macOS (bash/zsh)**

{% hint style="info" %}
Tested on macOS 12+ (Monterey, Ventura) in Terminal or iTerm2. Assumes a user account with Administrator (sudo) rights.
{% endhint %}

***

#### 1. Prerequisites

* **macOS 12 or later**
* **Homebrew** (optional but recommended)

  ```bash
  /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  ```
* **Terminal**: Built-in Terminal or [iTerm2](https://iterm2.com/)

***

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

You can either use Homebrew or `nvm` for installing/managing Node versions:

**Homebrew**

To install using homebrew, run the following command in your preferred terminal:

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

**nvm (Node Version Manager)**

To install using `nvm`, first install `nvm` and load it in your environment.

1. To install `nvm` run the following command:

   ```bash
   curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
   ```
2. To load `nvm`, add it to `~/.zshrc` or `~/.bash_profile`:

   ```bash
   export NVM_DIR="$HOME/.nvm"
   [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
   ```
3. Finally, install Node 22 by running the following command:

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

To verify the installation, you can check by running the following command:

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

***

#### Handling Gatekeeper & Remote-Signed Files Issues

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

* **Unblock downloaded files and allow apps from anywhere (requires sudo for allowing apps):**

  ```bash
  xattr -dr com.apple.quarantine ~/Downloads/<file>
  sudo spctl --master-disable
  ```

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

***

#### 4. Install the P0 CLI

{% hint style="info" %}
**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>
{% endhint %}

```bash
npm install -g @p0security/cli
```

> **Issue**: EACCES or permissions errors

* **Fix permissions and install PO CLI:**

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

To verify the installation, you can run the following commands:

```bash
p0 --version
p0 help
```

***

#### 5. macOS Shell Setup

For Shell setup, ensure `/usr/local/bin` (or `/opt/homebrew/bin`) is in your PATH:

````
```bash
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
```
````

You can enable command-completion by running the following commands:

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

***

#### 8. Proxy & Corporate Networks

> **Issue**: `npm install` stalling or `p0 login` failing behind proxy

* **Configure npm and Shell Proxy Settings:**

```bash
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.     |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.p0.dev/p0-cli/installing-p0-cli/macos.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
