Skip to content

feat(cli): add ignoreLocalDotEnv setting to isolate from project .env files#24473

Closed
soisyourface wants to merge 5 commits intogoogle-gemini:mainfrom
soisyourface:feature/ignore-local-dotenv
Closed

feat(cli): add ignoreLocalDotEnv setting to isolate from project .env files#24473
soisyourface wants to merge 5 commits intogoogle-gemini:mainfrom
soisyourface:feature/ignore-local-dotenv

Conversation

@soisyourface
Copy link
Copy Markdown

@soisyourface soisyourface commented Apr 1, 2026

Description

This PR introduces a new setting advanced.ignoreLocalDotEnv (defaulting to false) that allows users to explicitly opt-out of project-specific .env file loading.

When enabled, the CLI bypasses the search for .env and .gemini/.env files in the current workspace and parent directories, and instead falls back directly to the global configuration in ~/.gemini/.env.

Motivation

As discussed in #2493, the current aggressive loading of local .env files can cause significant issues for developers working in projects (like Rails, Laravel, or Symfony) where local environment variables conflict with the CLI's own configuration (e.g., GOOGLE_CLOUD_PROJECT or GEMINI_API_KEY).

This change provides a clean, settings-based way to ensure that Gemini CLI always uses the user's preferred global environment regardless of the project directory it is running in.

Changes

  • Settings Schema: Added ignoreLocalDotEnv to the advanced settings group.
  • Environment Loading: Updated findEnvFile to respect the new setting.
  • Tests: Added a unit test in settings.test.ts to verify the isolation logic.
  • Documentation: Regenerated settings documentation and JSON schema.

Verification Results

Verified that:

  1. When ignoreLocalDotEnv is false (default), local .env files are still loaded.
  2. When ignoreLocalDotEnv is true, local .env files are ignored and global variables are loaded.
  3. Successfully ran all tests in packages/cli/src/config/settings.test.ts.

Fixes #2493
Related to #19663 (provides an alternative isolation strategy)

@soisyourface soisyourface requested a review from a team as a code owner April 1, 2026 21:31
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses issues where local project environment variables conflict with the CLI's configuration. By introducing a new advanced setting, users can now isolate the CLI from local .env files, ensuring consistent behavior across different project environments by defaulting to global settings.

Highlights

  • New Configuration Setting: Added advanced.ignoreLocalDotEnv to the settings schema, allowing users to opt-out of loading project-specific .env files.
  • Environment Loading Logic: Updated findEnvFile to respect the new setting, enabling the CLI to bypass local directory searches and fall back directly to global configurations.
  • Test Coverage: Added a new unit test in settings.test.ts to verify that local .env files are correctly ignored when the setting is enabled.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new configuration setting, ignoreLocalDotEnv, which allows the CLI to bypass local and parent directory .env files in favor of the global ~/.gemini/.env file. The changes include updating the findEnvFile logic to conditionally skip directory traversal, adding the setting to the configuration schema, and providing a unit test to verify the new behavior. I have no feedback to provide.

@gemini-cli gemini-cli Bot added priority/p2 Important but can be addressed in a future release. area/core Issues related to User Interface, OS Support, Core Functionality labels Apr 1, 2026
@soisyourface soisyourface requested a review from a team as a code owner April 1, 2026 22:06
@gemini-cli
Copy link
Copy Markdown
Contributor

gemini-cli Bot commented Apr 16, 2026

Hi there! Thank you for your interest in contributing to Gemini CLI.

To ensure we maintain high code quality and focus on our prioritized roadmap, we have updated our contribution policy (see Discussion #17383).

We only guarantee review and consideration of pull requests for issues that are explicitly labeled as 'help wanted'. All other community pull requests are subject to closure after 14 days if they do not align with our current focus areas. For this reason, we strongly recommend that contributors only submit pull requests against issues explicitly labeled as 'help-wanted'.

This pull request is being closed as it has been open for 14 days without a 'help wanted' designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding and for being part of our community!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Issues related to User Interface, OS Support, Core Functionality priority/p2 Important but can be addressed in a future release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Isolate Gemini CLI from Project-Specific .env Files

1 participant