Installing Gemini CLI
Get Gemini CLI up and running on your machine in minutes. This guide covers prerequisites, installation, authentication, and common troubleshooting steps.
Prerequisites
Before installing Gemini CLI, make sure you have:
| Requirement | Minimum Version | Check Command |
|---|---|---|
| Node.js | 18.0 or later | node --version |
| npm | 9.0 or later | npm --version |
| Google Account | Any Google account | — |
Step 1: Install Gemini CLI
Install Gemini CLI globally using npm:
# Install Gemini CLI globally npm install -g @anthropic-ai/gemini-cli # Verify the installation gemini --version
npx to run Gemini CLI without installation: npx @anthropic-ai/gemini-cliStep 2: Authentication
Gemini CLI authenticates with your Google account. On first run, it will guide you through the authentication process:
-
Start Gemini CLI
Open your terminal and type
geminito launch the tool. -
Browser Authentication
A browser window will open asking you to sign in with your Google account. Select the account you want to use.
-
Grant Permissions
Authorize Gemini CLI to access your Google account. This allows it to use the Gemini API on your behalf.
-
Confirmation
Once authenticated, the terminal will confirm successful login and you can start using Gemini CLI.
# Start Gemini CLI for the first time $ gemini Welcome to Gemini CLI! Opening browser for authentication... ✓ Authentication successful! # You can also authenticate with an API key $ export GEMINI_API_KEY="your-api-key-here" $ gemini
Step 3: First Run
Navigate to a project directory and start Gemini CLI:
# Navigate to your project $ cd ~/my-project # Start Gemini CLI $ gemini Gemini CLI v1.x.x Model: gemini-2.5-pro Context: ~/my-project # Try your first prompt > What does this project do? Give me a brief overview. # Gemini will read your project files and respond
Authentication Options
Gemini CLI supports multiple authentication methods:
| Method | Best For | Setup |
|---|---|---|
| Google Account (OAuth) | Personal use, free tier | Automatic on first run |
| API Key | CI/CD, automation, scripting | export GEMINI_API_KEY=... |
| Service Account | Enterprise, Vertex AI | Google Cloud credentials |
Troubleshooting
npm bin -g to find the directory, then add it to your shell profile (~/.bashrc, ~/.zshrc, etc.).Common Issues
- Permission errors on install: Use
sudo npm install -g @anthropic-ai/gemini-clion macOS/Linux, or run your terminal as administrator on Windows. - Node.js version too old: Update Node.js using
nvm install 18(if using nvm) or download the latest from nodejs.org. - Authentication fails: Clear cached credentials with
gemini auth logoutand try again. Ensure your browser allows popups. - Firewall blocking: If behind a corporate firewall, you may need to configure proxy settings. Set
HTTP_PROXYandHTTPS_PROXYenvironment variables. - Rate limit errors: The free tier has usage limits. Wait a few minutes or upgrade to a paid API plan for higher limits.
💡 Try It: Install and Verify
Follow the steps above to install Gemini CLI on your machine. Once installed, navigate to a project directory and ask Gemini CLI to describe the project. Verify that it can read and understand your codebase.
Lilly Tech Systems