Install Gemini CLI on macOS

Complete guide for installing Gemini CLI on macOS 11 (Big Sur) and later.

Method 1: Install with Homebrew (Recommended)

The easiest way to install Gemini CLI on macOS is using Homebrew:

1. Install Homebrew (if not already installed):

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

2. Install Gemini CLI:

brew install gemini-cli

3. Verify installation:

gemini --version

Method 2: Install with npm

If you prefer using npm or need more control over the installation:

1. Install Node.js:

Option A: Using Homebrew

brew install node

Option B: Download from nodejs.org

Visit nodejs.org and download the macOS installer.

2. Install Gemini CLI globally:

npm install -g @google/gemini-cli

3. Fix npm permissions (if needed):

If you get permission errors:

# Option 1: Use a Node version manager (recommended)

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash

nvm install node

# Option 2: Change npm's default directory

mkdir ~/.npm-global

npm config set prefix '~/.npm-global'

echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.zshrc

source ~/.zshrc

Shell Configuration

Ensure your shell is properly configured:

For Zsh (default on macOS):

# Add to ~/.zshrc

export PATH="/usr/local/bin:$PATH"

# Reload configuration

source ~/.zshrc

For Bash:

# Add to ~/.bash_profile

export PATH="/usr/local/bin:$PATH"

# Reload configuration

source ~/.bash_profile

Apple Silicon (M1/M2/M3) Macs

For Apple Silicon Macs, Homebrew installs to a different location:

# Add Homebrew to PATH

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zshrc

eval "$(/opt/homebrew/bin/brew shellenv)"

Common Issues

Command not found: gemini

Make sure the installation directory is in your PATH:

echo $PATH

which gemini

Permission denied errors

Never use sudo with npm. Instead, fix npm permissions:

npm config get prefix

npm config set prefix '~/.npm-global'

Next Steps

Great! Gemini CLI is now installed on your Mac. Configure your API key to start using it: