243 words
1 minutes
Gemini CLI Installation Guide for Mac - 3 Auth Methods

Introduction#

Following the trend of CLI agents, I installed Gemini CLI this time.

There are surprisingly many installation methods. Environment:

  • macOS (Tahoe 26)
  • Node.js 22


Installation Methods#

Three main installation methods available.

Homebrew (Easy)

brew install gemini-cli

npm Global Install (Node.js 20+)

npm install -g @google/gemini-cli

npx for Trial

npx https://github.com/google-gemini/gemini-cli

Authentication#

Gemini CLI supports 3 authentication methods. Most people will use Google login.

Google Login

gemini
# Follow on-screen instructions to log in via browser

Note: If under 18 or using Workspace account, you may need Google Cloud Project ID. Google, please be more lenient

export GOOGLE_CLOUD_PROJECT="YOUR_PROJECT_ID"

Gemini API Key (AI Studio)

Get API key and set as environment variable:

export GEMINI_API_KEY="YOUR_API_KEY"

Vertex AI

export GOOGLE_GENAI_USE_VERTEXAI=true
export GOOGLE_API_KEY="YOUR_API_KEY"

Don’t forget to reload shell config after writing to config file.


Usage#

Useful options to know:

# First command to try
gemini

# Non-interactive mode
gemini -p "Hello from macOS"

# Want to use Flash? (Change model)
gemini -m gemini-2.5-flash -p "Summarize this project structure"

Update & Uninstall#

How to remove when needed:

# brew
brew upgrade gemini-cli     # Update
brew uninstall gemini-cli   # Uninstall

# npm
npm update -g @google/gemini-cli   # Update
npm uninstall -g @google/gemini-cli # Uninstall

Troubleshooting#

“command not found: gemini”

  • Brew: brew doctorbrew reinstall gemini-cli

  • npm: Verify PATH includes npm prefix -g

    echo 'export PATH="$(npm prefix -g)/bin:$PATH"' >> ~/.zshrc
    source ~/.zshrc

Authentication fails

  • Check Google account permissions
  • Verify API key validity
  • Ensure Project ID is set (if required)

Browser doesn’t open (can’t log in)

  • For headless/SSH environments, use API key method

Usage Limits#

  • Google Login (personal): Approximately 60 requests/min · 1,000 requests/day free tier.
  • Gemini API Key (AI Studio): Free tier 100 requests/day (varies by model and time).

References#

Gemini CLI Installation Guide for Mac - 3 Auth Methods
https://naonao-na.com/en/posts/gemini-cli-install-mac/
Author
[object Object]
Published at
2025-10-13