A comprehensive guide to installing and configuring Google's Gemini CLI on macOS, with step-by-step instructions and troubleshooting tips.
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.
node -v
)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
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
After installation, running Gemini CLI for the first time will guide you through a setup process:
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.
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.
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.
# Run authentication setup
gemini auth login
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!"
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
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.
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.
sudo npm install -g @google/gemini-cli
Ensure you have a stable internet connection and try switching to global proxy mode if using a VPN.
brew install node@18
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.zshrc
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.