How to Install Gemini CLI on Mac

A comprehensive guide to installing and configuring Google's Gemini CLI on macOS, with step-by-step instructions and troubleshooting tips.

What is Gemini CLI?

Gemini CLI is an open-source command-line AI tool developed by Google's Gemini team specifically for developers. It can understand code, execute complex queries, automate tasks, and leverage Gemini's multimodal capabilities (such as image recognition) to generate creative content.

Key Features

  • Handling Large Codebases: Supports over 1 million token context length for analyzing large projects
  • Multimodal Application Generation: Quickly generate application prototypes through PDFs or sketches
  • DevOps Task Automation: Git operations, PR queries, code migration planning, etc.
  • External Tool Integration: Connect to media generation models like Imagen, Veo, and Lyria through MCP server
  • Web Search Support: Built-in Google Search ensures answers based on the latest information

System Requirements

Prerequisites for macOS

  • Node.js: Version 18.0.0 or higher (check with node -v)
  • npm: Latest version recommended (included with Node.js)
  • macOS: 10.15 Catalina or newer
  • Internet Connection: Required for authentication and API access

Installation Methods for Mac

Method 1: Direct Execution (No Installation)

If you want to try Gemini CLI without installing it globally, you can run it directly using npx:

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

Method 2: Global Installation (Recommended)

For regular use, it's recommended to install Gemini CLI globally on your Mac:

# Standard installation
npm install -g @google/gemini-cli

# If you encounter permission issues, use sudo
sudo npm install -g @google/gemini-cli

# For Apple Silicon Macs (M1/M2/M3)
arch -arm64 npm install -g @google/gemini-cli

# Verify installation
gemini --version
which gemini
Gemini CLI Terminal Interface

First-Time Setup Guide

After installation, running Gemini CLI for the first time will guide you through a setup process:

Step 1: Choose Theme Style

When you first launch Gemini CLI by typing gemini in your terminal, you'll be prompted to select a theme. Choose the default theme or any other available option and press Enter to continue.

Step 2: Select Authentication Method

You'll be asked to choose an authentication method. The recommended option is "Login with Google," which provides 60 requests per minute and 1000 requests per day for free. Select your preferred method and press Enter.

Step 3: Browser Authorization

After confirmation, your browser will open for you to log in with your Google account. If you encounter a "localhost refused connection" error, ensure your network connection is properly configured and retry.

Authentication Methods

Method 1: Google Login (Recommended)

# Run authentication setup
gemini auth login

Method 2: API Key (For Higher Usage Limits)

If you need higher request frequency or enterprise-level access, you can use an API Key:

# Get your API Key from Google AI Studio first
# Then set the environment variable
export GEMINI_API_KEY="your-api-key-from-google-ai-studio"

# Test authentication
gemini "Hello, Gemini!"

Quick Start Guide

Once installed and authenticated, you can start using Gemini CLI right away:

# Start an interactive session
gemini

# Ask a direct question
gemini "What's the capital of France?"

# Include local files in your query (use @ to select files)
gemini "Explain this code" @path/to/yourfile.js

# Get help with available commands
gemini help

Using Gemini CLI in VSCode

Gemini CLI works seamlessly in VSCode's integrated terminal. Launch VSCode, open the terminal, and start Gemini CLI with the gemini command. You can then use the @ command to select files from your workspace for context-aware AI assistance.

Advanced Usage Tips

Type / in the Gemini CLI interactive mode to see available commands and shortcuts. If you experience network issues, Gemini CLI will automatically switch from gemini-2.5-pro to gemini-2.5-flash model for better performance.

Troubleshooting

Common Issues on Mac

Permission Errors:
sudo npm install -g @google/gemini-cli
Authentication Failures:

Ensure you have a stable internet connection and try switching to global proxy mode if using a VPN.

Node.js Version Issues:
brew install node@18
Path Issues:
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.zshrc

Next Steps

Now that you've successfully installed Gemini CLI on your Mac, continue to Getting Started to learn the basics, or explore Commands for the complete reference.