.env files.
.env File Loading
The CLI automatically loads environment variables from.env files in the following order:
Parent Directories
Searches upward in parent directories until finding an
.env file, reaching a .git folder, or reaching the home directoryAuthentication
Your Google Cloud API key (required for Vertex AI in express mode)
Path to your Google Application Credentials JSON file
Your Google Cloud Project ID (required for Code Assist or Vertex AI)
In Cloud Shell, this defaults to a special project for Cloud Shell users. To use a different project in Cloud Shell, define it in a
.env file.Your Google Cloud Project Location (required for Vertex AI in non-express mode)
Enable Vertex AI mode
Specifies the API version to use for Gemini API requests
Model Configuration
Specifies the default Gemini model to useOverrides the hardcoded default
CLI Behavior
Specifies the root directory for Gemini CLI’s user-level configuration and storageBy default, this is the user’s system home directory. The CLI will create a
.gemini folder inside this directory.Useful for shared compute environments or keeping CLI state isolated.Manually specifies the PID of the IDE process to use for integrationUseful when running Gemini CLI in a standalone terminal while associating it with a specific IDE instance.
Set to any value to disable all color output in the CLI
Set to a string to customize the title of the CLI
Set to
true or 1 to enable verbose debug loggingThis variable is automatically excluded from project
.env files by default.Alternative to
DEBUG for enabling debug modeSandboxing
Alternative to the
sandbox setting in settings.jsonOptions: true, false, docker, podman, or a custom command stringAutomatically build the custom sandbox image from
.gemini/sandbox.DockerfileSwitches the Seatbelt (
sandbox-exec) profile on macOSOptions:permissive-open(default) - Restricts writes to project folder but allows other operationsrestrictive-open- Declines operations by default, allows networkstrict-open- Restricts reads/writes to working directory, allows networkstrict-proxied- Same asstrict-openbut routes network through proxy<profile_name>- Uses custom profile from.gemini/sandbox-macos-<profile_name>.sb
System Prompts
Replaces the built-in system prompt with content from a Markdown fileOptions:
true/1- Use project default path./.gemini/system.md- Any other string - Treat as a path (relative/absolute supported,
~expands) false/0or unset - Use the built-in prompt
Writes the current built-in system prompt to a file for reviewOptions:
true/1- Write to./.gemini/system.md- Otherwise treat the value as a path
Telemetry
Set to
true or 1 to enable telemetryOverrides the telemetry.enabled settingSets the telemetry targetOptions:
local, gcpOverrides the telemetry.target settingSets the OTLP endpoint for telemetryOverrides the
telemetry.otlpEndpoint settingSets the OTLP protocolOptions:
grpc, httpOverrides the telemetry.otlpProtocol settingSet to
true or 1 to enable logging of user promptsOverrides the telemetry.logPrompts settingSets the file path to write telemetry to when target is
localOverrides the telemetry.outfile settingSet to
true or 1 to enable using an external OTLP collectorOverrides the telemetry.useCollector settingYour Google Cloud Project ID for Telemetry in Google Cloud
System Configuration
Override the path to the system defaults fileDefault locations:
- Linux:
/etc/gemini-cli/system-defaults.json - Windows:
C:\ProgramData\gemini-cli\system-defaults.json - macOS:
/Library/Application Support/GeminiCli/system-defaults.json
Override the path to the system settings fileDefault locations:
- Linux:
/etc/gemini-cli/settings.json - Windows:
C:\ProgramData\gemini-cli\settings.json - macOS:
/Library/Application Support/GeminiCli/settings.json
Specifies the endpoint for the code assist serverUseful for development and testing
Environment Variable Redaction
To prevent accidental leakage of sensitive information, Gemini CLI automatically redacts potential secrets from environment variables when executing tools.Default Redaction Rules
By Name
By Name
Variables are redacted if their names contain:
TOKENSECRETPASSWORDKEYAUTHCREDENTIALPRIVATECERT
By Value Pattern
By Value Pattern
Variables are redacted if their values match:
- Private keys (RSA, OpenSSH, PGP, etc.)
- Certificates
- URLs containing credentials
- API keys and tokens (GitHub, Google, AWS, Stripe, Slack, etc.)
Specific Blocklist
Specific Blocklist
These variables are always redacted by default:
CLIENT_IDDB_URIDATABASE_URLCONNECTION_STRING
Never Redacted (Allowlist)
- Common system variables:
PATH,HOME,USER,SHELL,TERM,LANG - Variables starting with
GEMINI_CLI_ - GitHub Action specific variables
Custom Redaction Configuration
Configure redaction behavior in yoursettings.json:
Enable redaction of environment variables that may contain secrets
Environment variables to always allow (bypass redaction)
Environment variables to always redact
Example Configurations
Basic Setup with API Key
Vertex AI Configuration
Development Setup with Debug
Sandboxed Environment
Custom Home Directory (Shared Computing)
Shell Profile Examples
Bash (~/.bashrc)
Zsh (~/.zshrc)
PowerShell (Windows)
Related Resources
Settings Reference
Configure Gemini CLI with settings.json
Authentication
Complete authentication setup guide
Sandboxing
Safe execution environments
Telemetry
Usage tracking and monitoring