|
| 1 | +--- |
| 2 | +title: Gemini CLI |
| 3 | + |
| 4 | +author: Jason Andrews |
| 5 | +minutes_to_complete: 15 |
| 6 | +official_docs: https://ai.google.dev/gemini-api/docs/cli |
| 7 | + |
| 8 | +test_maintenance: true |
| 9 | +test_images: |
| 10 | +- ubuntu:latest |
| 11 | + |
| 12 | +layout: installtoolsall |
| 13 | +multi_install: false |
| 14 | +multitool_install_part: false |
| 15 | +tool_install: true |
| 16 | +weight: 1 |
| 17 | +--- |
| 18 | + |
| 19 | +Gemini CLI is Google's command-line interface for interacting with the Gemini AI assistant. You can use it to ask questions about software development, architecture, and general programming tasks with advanced AI capabilities. |
| 20 | + |
| 21 | +It supports multiple operating systems, including Arm Linux distributions and macOS, and provides powerful AI assistance for developers working on Arm platforms. |
| 22 | + |
| 23 | +This guide explains how to install Gemini CLI on macOS and Arm Linux. |
| 24 | + |
| 25 | +## What should I do before installing Gemini CLI? |
| 26 | + |
| 27 | +You need a Google account to use Gemini CLI. If you don't have one, visit [Google Account Creation](https://accounts.google.com/signup) to create your account. |
| 28 | + |
| 29 | +You'll also need to set up authentication for the Gemini API. Gemini CLI supports multiple authentication methods, with Google OAuth login being the recommended approach for most users. |
| 30 | + |
| 31 | +## How do I set up authentication for Gemini CLI? |
| 32 | + |
| 33 | +Gemini CLI offers three authentication methods. Choose the one that best fits your needs. |
| 34 | + |
| 35 | +### Option 1: Google OAuth login |
| 36 | + |
| 37 | +This is your Google account, and is the easiest method for most users. After installing Gemini CLI, run the tool and select "Login with Google" when prompted. This opens your browser for authentication. |
| 38 | + |
| 39 | +Benefits of using Google OAuth: |
| 40 | +- Free tier includes 60 requests per minute and 1,000 requests per day |
| 41 | +- Access to Gemini with 1M token context window |
| 42 | +- No manual API key management required |
| 43 | + |
| 44 | +### Option 2: Gemini API key |
| 45 | + |
| 46 | +If you prefer using an API key, you can generate one from Google AI Studio. |
| 47 | + |
| 48 | +To get your API key: |
| 49 | +1. Visit [Google AI Studio](https://aistudio.google.com/apikey) |
| 50 | +2. Sign in with your Google account |
| 51 | +3. Click "Create API Key" |
| 52 | +4. Copy the generated key |
| 53 | + |
| 54 | +Set the API key in your environment: |
| 55 | + |
| 56 | +```bash |
| 57 | +export GEMINI_API_KEY="YOUR_API_KEY" |
| 58 | +``` |
| 59 | + |
| 60 | +Benefits of using an API key: |
| 61 | +- Free tier includes 250 requests per day |
| 62 | +- Works well for automated scripts and CI/CD environments |
| 63 | +- No interactive authentication required |
| 64 | + |
| 65 | +### Option 3: Vertex AI for enterprise users |
| 66 | + |
| 67 | +For enterprise users with Google Cloud accounts, you can use Vertex AI authentication. |
| 68 | + |
| 69 | +Set up Vertex AI authentication: |
| 70 | + |
| 71 | +```bash |
| 72 | +export GOOGLE_API_KEY="YOUR_GOOGLE_CLOUD_API_KEY" |
| 73 | +export GOOGLE_GENAI_USE_VERTEXAI=true |
| 74 | +``` |
| 75 | + |
| 76 | +Benefits of using Vertex AI: |
| 77 | +- Enterprise-grade features and support |
| 78 | +- Integration with Google Cloud billing and management |
| 79 | +- Higher rate limits and advanced features |
| 80 | + |
| 81 | +## How do I install Gemini CLI on macOS? |
| 82 | + |
| 83 | +The easiest way to install Gemini CLI on macOS is using Homebrew, which handles all dependencies automatically. |
| 84 | + |
| 85 | +### Install Gemini CLI on macOS using Homebrew |
| 86 | + |
| 87 | +Yes, you can install [Homebrew](https://brew.sh/) if it isn't already available on your computer. |
| 88 | + |
| 89 | +Install Gemini CLI using Homebrew: |
| 90 | + |
| 91 | +```console |
| 92 | +brew install gemini-cli |
| 93 | +``` |
| 94 | + |
| 95 | +This installs Gemini CLI and automatically handles the Node.js dependency. The Homebrew version is currently at 0.19.4 (stable) and receives regular updates. |
| 96 | + |
| 97 | +### Install Gemini CLI on macOS using npm |
| 98 | + |
| 99 | +Yes, if you prefer to use npm or need the latest version, you can install Gemini CLI globally using npm. |
| 100 | + |
| 101 | +First, make sure you have Node.js version 20 or higher installed. Install Node.js using Homebrew: |
| 102 | + |
| 103 | +```console |
| 104 | +brew install node |
| 105 | +``` |
| 106 | + |
| 107 | +Verify Node.js is installed correctly: |
| 108 | + |
| 109 | +```console |
| 110 | +node --version |
| 111 | +``` |
| 112 | + |
| 113 | +The output should show version 20 or higher: |
| 114 | + |
| 115 | +```output |
| 116 | +v25.2.1 |
| 117 | +``` |
| 118 | + |
| 119 | +Install Gemini CLI globally using npm: |
| 120 | + |
| 121 | +```console |
| 122 | +npm install -g @google/gemini-cli |
| 123 | +``` |
| 124 | + |
| 125 | +This installs the latest version (for example, 0.20.0) directly from npm. Homebrew can lag behind npm, so versions may differ. |
| 126 | + |
| 127 | +### How do I confirm Gemini CLI is working on macOS? |
| 128 | + |
| 129 | +You now have Gemini CLI installed on your macOS system. |
| 130 | + |
| 131 | +Confirm the CLI is available by checking the version: |
| 132 | + |
| 133 | +```console |
| 134 | +gemini --version |
| 135 | +``` |
| 136 | + |
| 137 | +The output shows the version: |
| 138 | + |
| 139 | +```output |
| 140 | +0.20.0 |
| 141 | +``` |
| 142 | + |
| 143 | +Start an interactive session to test basic functionality: |
| 144 | + |
| 145 | +```console |
| 146 | +gemini |
| 147 | +``` |
| 148 | + |
| 149 | +This opens the Gemini CLI interface where you can authenticate and start asking questions. On first run, you'll be prompted to choose your authentication method. |
| 150 | + |
| 151 | +## How do I install Gemini CLI on Arm Linux? |
| 152 | + |
| 153 | +You can install Gemini CLI on Arm Linux distributions using npm. This method works on all major Arm Linux distributions including Ubuntu, Debian, CentOS, and others. |
| 154 | + |
| 155 | +### What packages do I need before installing Gemini CLI on Arm Linux? |
| 156 | + |
| 157 | +Before installing Gemini CLI, install prerequisite packages and Node.js. |
| 158 | + |
| 159 | +Install the required packages on Ubuntu/Debian systems: |
| 160 | + |
| 161 | +```bash |
| 162 | +sudo apt update && sudo apt install -y curl |
| 163 | +``` |
| 164 | + |
| 165 | +If you are not using Ubuntu/Debian use your package manager to install curl. |
| 166 | + |
| 167 | +### How do I install Node.js on Arm Linux? |
| 168 | + |
| 169 | +Gemini CLI requires Node.js version 20 or higher. The easiest way to install Node.js on Arm Linux is using the NodeSource repository. |
| 170 | + |
| 171 | +Download and run the Node.js 20.x setup script: |
| 172 | + |
| 173 | +```bash |
| 174 | +curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - |
| 175 | +``` |
| 176 | + |
| 177 | +Verify Node.js is installed correctly: |
| 178 | + |
| 179 | +```bash |
| 180 | +node --version |
| 181 | +``` |
| 182 | + |
| 183 | +The output should show version 20 or higher: |
| 184 | + |
| 185 | +```output |
| 186 | +v20.19.4 |
| 187 | +``` |
| 188 | + |
| 189 | +Verify npm is available: |
| 190 | + |
| 191 | +```bash |
| 192 | +npm --version |
| 193 | +``` |
| 194 | + |
| 195 | +The output shows the npm version: |
| 196 | + |
| 197 | +```output |
| 198 | +10.2.4 |
| 199 | +``` |
| 200 | + |
| 201 | +### How do I install Gemini CLI using npm on Arm Linux? |
| 202 | + |
| 203 | +With Node.js installed, install Gemini CLI globally using npm. |
| 204 | + |
| 205 | +Install Gemini CLI globally: |
| 206 | + |
| 207 | +```bash |
| 208 | +sudo npm install -g @google/gemini-cli |
| 209 | +``` |
| 210 | + |
| 211 | +This downloads and installs the latest version of Gemini CLI. The installation may take a few minutes as it downloads dependencies. |
| 212 | + |
| 213 | +### How do I confirm Gemini CLI is working on Arm Linux? |
| 214 | + |
| 215 | +You now have Gemini CLI installed on your Arm Linux system. |
| 216 | + |
| 217 | +Confirm the CLI is available by checking the version: |
| 218 | + |
| 219 | +```bash |
| 220 | +gemini --version |
| 221 | +``` |
| 222 | + |
| 223 | +The output shows the version: |
| 224 | + |
| 225 | +```output |
| 226 | +0.20.0 |
| 227 | +``` |
| 228 | + |
| 229 | +### How do I view the available command-line options? |
| 230 | + |
| 231 | +To print the available commands and options, use the `--help` flag: |
| 232 | + |
| 233 | +```bash |
| 234 | +gemini --help |
| 235 | +``` |
| 236 | + |
| 237 | +The output shows the available commands and options: |
| 238 | + |
| 239 | +```output |
| 240 | +Usage: gemini [options] [command] |
| 241 | +
|
| 242 | +Gemini CLI - Launch an interactive CLI, use -p/--prompt for non-interactive mode |
| 243 | +
|
| 244 | +Commands: |
| 245 | + gemini [query..] Launch Gemini CLI [default] |
| 246 | + gemini mcp Manage MCP servers |
| 247 | + gemini extensions <command> Manage Gemini CLI extensions. [aliases: extension] |
| 248 | +
|
| 249 | +Positionals: |
| 250 | + query Positional prompt. Defaults to one-shot; use -i/--prompt-interactive for interactive. |
| 251 | +
|
| 252 | +Options: |
| 253 | + -d, --debug Run in debug mode? [boolean] [default: false] |
| 254 | + -m, --model Model [string] |
| 255 | + -p, --prompt Prompt. Appended to input on stdin (if any). |
| 256 | + [deprecated: Use the positional prompt instead. This flag will be removed in a future version.] [string] |
| 257 | + -i, --prompt-interactive Execute the provided prompt and continue in interactive mode [string] |
| 258 | + -s, --sandbox Run in sandbox? [boolean] |
| 259 | + -y, --yolo Automatically accept all actions (aka YOLO mode, see https://www.youtube.com/watch?v=xvFZjo5PgG0 |
| 260 | + for more details)? [boolean] [default: false] |
| 261 | + --approval-mode Set the approval mode: default (prompt for approval), auto_edit (auto-approve edit tools), yolo |
| 262 | + (auto-approve all tools) [string] [choices: "default", "auto_edit", "yolo"] |
| 263 | + --experimental-acp Starts the agent in ACP mode [boolean] |
| 264 | + --allowed-mcp-server-names Allowed MCP server names [array] |
| 265 | + --allowed-tools Tools that are allowed to run without confirmation [array] |
| 266 | + -e, --extensions A list of extensions to use. If not provided, all extensions are used. [array] |
| 267 | + -l, --list-extensions List all available extensions and exit. [boolean] |
| 268 | + -r, --resume Resume a previous session. Use "latest" for most recent or index number (e.g. --resume 5) |
| 269 | + [string] |
| 270 | + --list-sessions List available sessions for the current project and exit. [boolean] |
| 271 | + --delete-session Delete a session by index number (use --list-sessions to see available sessions). [string] |
| 272 | + --include-directories Additional directories to include in the workspace (comma-separated or multiple |
| 273 | + --include-directories) [array] |
| 274 | + --screen-reader Enable screen reader mode for accessibility. [boolean] |
| 275 | + -o, --output-format The format of the CLI output. [string] [choices: "text", "json", "stream-json"] |
| 276 | + -v, --version Show version number [boolean] |
| 277 | + -h, --help Show help |
| 278 | +``` |
| 279 | + |
| 280 | +Your Gemini CLI installation on Arm Linux is now complete and ready to use. |
| 281 | + |
| 282 | +## How do I configure context for Arm development? |
| 283 | + |
| 284 | +Context configuration allows you to provide Gemini with persistent information about your development environment, preferences, and project details. This helps Gemini give more relevant and tailored responses for Arm architecture development. |
| 285 | + |
| 286 | +### How do I create a context file for Gemini CLI? |
| 287 | + |
| 288 | +Gemini CLI looks for context files in your home directory's `.gemini` configuration folder. Create this directory and add your context file. |
| 289 | + |
| 290 | +Create the Gemini configuration directory: |
| 291 | + |
| 292 | +```bash |
| 293 | +mkdir -p ~/.gemini |
| 294 | +``` |
| 295 | + |
| 296 | +Create a context file with Arm development information: |
| 297 | + |
| 298 | +```bash |
| 299 | +cat > ~/.gemini/GEMINI.md << 'EOF' |
| 300 | +I am an Arm Linux developer. I prefer Ubuntu and other Debian based distributions. I don't use any x86 computers so please provide all information assuming I'm working on Arm Linux. Sometimes I use macOS and Windows on Arm, but please only provide information about these operating systems when I ask for it. |
| 301 | +EOF |
| 302 | +``` |
| 303 | + |
| 304 | +This creates a context file that tells Gemini about your Arm development focus and preferences. |
| 305 | + |
| 306 | +### How do I verify that context is being loaded? |
| 307 | + |
| 308 | +Verify that Gemini is loading your context file by starting a chat session and asking a development question. |
| 309 | + |
| 310 | +Start Gemini CLI: |
| 311 | + |
| 312 | +```console |
| 313 | +gemini |
| 314 | +``` |
| 315 | + |
| 316 | +Ask a question that should trigger context-aware responses: |
| 317 | + |
| 318 | +```output |
| 319 | +How do I install gcloud? |
| 320 | +``` |
| 321 | + |
| 322 | +If context is loaded correctly, Gemini should provide Arm-specific recommendations. |
| 323 | + |
| 324 | +## How do I integrate the Arm MCP server with Gemini CLI? |
| 325 | + |
| 326 | +The Arm MCP (Model Context Protocol) server provides Gemini CLI with specialized tools and knowledge for Arm architecture development, migration, and optimization. By integrating the Arm MCP server, you gain access to Arm-specific documentation, code analysis tools, and optimization recommendations directly through your Gemini conversations. |
| 327 | + |
| 328 | +### How do I set up the Arm MCP server with Docker? |
| 329 | + |
| 330 | +The Arm MCP server runs as a Docker container that Gemini CLI connects to via the Model Context Protocol. You need Docker installed on your system to use the MCP server. |
| 331 | + |
| 332 | +First, ensure Docker is installed and running on your system. Install Docker by following the [Docker installation guide](/install-guides/docker/). |
| 333 | + |
| 334 | +Pull the Arm MCP server Docker image: |
| 335 | + |
| 336 | +```console |
| 337 | +docker pull armlimited/arm-mcp:latest |
| 338 | +``` |
| 339 | + |
| 340 | +### How do I configure Gemini CLI to use the Arm MCP server? |
| 341 | + |
| 342 | +Gemini CLI uses a configuration file to connect to MCP servers. Create or update this configuration to include the Arm MCP server. |
| 343 | + |
| 344 | +Use an editor to modify the file `~/.gemini/settings.json` to add an MCP object. |
| 345 | + |
| 346 | +You may have other objects already in the file so make sure to use a `,` at the end of each object that is not the last one. For example, the code below shows both the `security` and the `mcpServers` objects. |
| 347 | + |
| 348 | +```json |
| 349 | +{ |
| 350 | + "security": { |
| 351 | + "auth": { |
| 352 | + "selectedType": "oauth-personal" |
| 353 | + } |
| 354 | + }, |
| 355 | + "mcpServers": { |
| 356 | + "arm_mcp_server": { |
| 357 | + "command": "docker", |
| 358 | + "args": [ |
| 359 | + "run", |
| 360 | + "--rm", |
| 361 | + "-i", |
| 362 | + "-v", "/Users/yourname01/yourlocalcodebase:/workspace", |
| 363 | + "--name", "arm-mcp", |
| 364 | + "armlimited/arm-mcp:latest" |
| 365 | + ], |
| 366 | + "env": {}, |
| 367 | + "timeout": 60000 |
| 368 | + } |
| 369 | + } |
| 370 | +} |
| 371 | +``` |
| 372 | + |
| 373 | +This configuration tells Gemini CLI to connect to the Arm MCP server running in the Docker container. |
| 374 | + |
| 375 | +### How do I verify the Arm MCP server is working? |
| 376 | + |
| 377 | +Start the Gemini CLI and list the tools from the MCP server to verify it's working: |
| 378 | + |
| 379 | +```console |
| 380 | +gemini |
| 381 | +``` |
| 382 | + |
| 383 | +Use the `/tools` command to list the available tools: |
| 384 | + |
| 385 | +```console |
| 386 | +/tools |
| 387 | +``` |
| 388 | + |
| 389 | +You should see the Arm MCP server tools listed in the output. If the arm-mcp server says it's still loading, wait a moment and run `/tools` again. |
| 390 | + |
| 391 | +If you're facing issues or have questions, reach out to [email protected] . |
| 392 | + |
| 393 | +You're ready to use the Gemini CLI. |
0 commit comments