summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorOleksandr Gotgelf <[email protected]>2025-08-03 20:44:15 +0200
committerGitHub <[email protected]>2025-08-03 18:44:15 +0000
commit03ed37d0dc2b5e2077b53073517abaab3d24d9c2 (patch)
treee84a6cadef21cc6862b12215153b3e1177a1732d /docs
parentbedcbb9feb3b4f5fcdd9d64782f3ee1e06376715 (diff)
fix: exclude DEBUG and DEBUG_MODE from project .env files by default (#5289)
Co-authored-by: Jacob Richman <[email protected]>
Diffstat (limited to 'docs')
-rw-r--r--docs/cli/authentication.md2
-rw-r--r--docs/cli/configuration.md14
-rw-r--r--docs/sandbox.md2
-rw-r--r--docs/troubleshooting.md5
4 files changed, 22 insertions, 1 deletions
diff --git a/docs/cli/authentication.md b/docs/cli/authentication.md
index 8e534d0b..d9adcfb1 100644
--- a/docs/cli/authentication.md
+++ b/docs/cli/authentication.md
@@ -91,6 +91,8 @@ The Gemini CLI requires you to authenticate with Google's AI services. On initia
You can create a **`.gemini/.env`** file in your project directory or in your home directory. Creating a plain **`.env`** file also works, but `.gemini/.env` is recommended to keep Gemini variables isolated from other tools.
+**Important:** Some environment variables (like `DEBUG` and `DEBUG_MODE`) are automatically excluded from project `.env` files to prevent interference with gemini-cli behavior. Use `.gemini/.env` files for gemini-cli specific variables.
+
Gemini CLI automatically loads environment variables from the **first** `.env` file it finds, using the following search order:
1. Starting in the **current directory** and moving upward toward `/`, for each directory it checks:
diff --git a/docs/cli/configuration.md b/docs/cli/configuration.md
index 695a7c53..ce9b55bc 100644
--- a/docs/cli/configuration.md
+++ b/docs/cli/configuration.md
@@ -240,6 +240,14 @@ In addition to a project settings file, a project's `.gemini` directory can cont
}
```
+- **`excludedProjectEnvVars`** (array of strings):
+ - **Description:** Specifies environment variables that should be excluded from being loaded from project `.env` files. This prevents project-specific environment variables (like `DEBUG=true`) from interfering with gemini-cli behavior. Variables from `.gemini/.env` files are never excluded.
+ - **Default:** `["DEBUG", "DEBUG_MODE"]`
+ - **Example:**
+ ```json
+ "excludedProjectEnvVars": ["DEBUG", "DEBUG_MODE", "NODE_ENV"]
+ ```
+
### Example `settings.json`:
```json
@@ -271,7 +279,8 @@ In addition to a project settings file, a project's `.gemini` directory can cont
"run_shell_command": {
"tokenBudget": 100
}
- }
+ },
+ "excludedProjectEnvVars": ["DEBUG", "DEBUG_MODE", "NODE_ENV"]
}
```
@@ -293,6 +302,8 @@ The CLI automatically loads environment variables from an `.env` file. The loadi
2. If not found, it searches upwards in parent directories until it finds an `.env` file or reaches the project root (identified by a `.git` folder) or the home directory.
3. If still not found, it looks for `~/.env` (in the user's home directory).
+**Environment Variable Exclusion:** Some environment variables (like `DEBUG` and `DEBUG_MODE`) are automatically excluded from being loaded from project `.env` files to prevent interference with gemini-cli behavior. Variables from `.gemini/.env` files are never excluded. You can customize this behavior using the `excludedProjectEnvVars` setting in your `settings.json` file.
+
- **`GEMINI_API_KEY`** (Required):
- Your API key for the Gemini API.
- **Crucial for operation.** The CLI will not function without it.
@@ -332,6 +343,7 @@ The CLI automatically loads environment variables from an `.env` file. The loadi
- `<profile_name>`: Uses a custom profile. To define a custom profile, create a file named `sandbox-macos-<profile_name>.sb` in your project's `.gemini/` directory (e.g., `my-project/.gemini/sandbox-macos-custom.sb`).
- **`DEBUG` or `DEBUG_MODE`** (often used by underlying libraries or the CLI itself):
- Set to `true` or `1` to enable verbose debug logging, which can be helpful for troubleshooting.
+ - **Note:** These variables are automatically excluded from project `.env` files by default to prevent interference with gemini-cli behavior. Use `.gemini/.env` files if you need to set these for gemini-cli specifically.
- **`NO_COLOR`**:
- Set to any value to disable all color output in the CLI.
- **`CLI_TITLE`**:
diff --git a/docs/sandbox.md b/docs/sandbox.md
index 508a0d03..20a1a3b5 100644
--- a/docs/sandbox.md
+++ b/docs/sandbox.md
@@ -129,6 +129,8 @@ export SANDBOX_SET_UID_GID=false # Disable UID/GID mapping
DEBUG=1 gemini -s -p "debug command"
```
+**Note:** If you have `DEBUG=true` in a project's `.env` file, it won't affect gemini-cli due to automatic exclusion. Use `.gemini/.env` files for gemini-cli specific debug settings.
+
### Inspect sandbox
```bash
diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md
index fa88e26e..8c500445 100644
--- a/docs/troubleshooting.md
+++ b/docs/troubleshooting.md
@@ -53,6 +53,11 @@ This guide provides solutions to common issues and debugging tips.
- **Cause:** The `is-in-ci` package checks for the presence of `CI`, `CONTINUOUS_INTEGRATION`, or any environment variable with a `CI_` prefix. When any of these are found, it signals that the environment is non-interactive, which prevents the CLI from starting in its interactive mode.
- **Solution:** If the `CI_` prefixed variable is not needed for the CLI to function, you can temporarily unset it for the command. e.g., `env -u CI_TOKEN gemini`
+- **DEBUG mode not working from project .env file**
+ - **Issue:** Setting `DEBUG=true` in a project's `.env` file doesn't enable debug mode for gemini-cli.
+ - **Cause:** The `DEBUG` and `DEBUG_MODE` variables are automatically excluded from project `.env` files to prevent interference with gemini-cli behavior.
+ - **Solution:** Use a `.gemini/.env` file instead, or configure the `excludedProjectEnvVars` setting in your `settings.json` to exclude fewer variables.
+
## Debugging Tips
- **CLI debugging:**