gemini-cli - ✅(Solved) Fix Support boolean types when configuring `settings.json` via environment variables [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
google-gemini/gemini-cli#25573Fetched 2026-04-18 05:57:52
View on GitHub
Comments
1
Participants
2
Timeline
7
Reactions
0
Timeline (top)
labeled ×3commented ×1cross-referenced ×1issue_type_added ×1

Error Message

Error in: ui.autoThemeSwitching

Root Cause

I want to set the autoThemeSwitching flag via environment variables. This is because Gemini CLI wrongly identifies my shell as light when it is actually dark. And I can't rely on a static value, such as setting autoThemeSwitching to false, because I have multiple VTEs, some dark and some light.

PR fix notes

PR #25608: fix(cli): coerce env-resolved boolean strings in settings

Description (problem / solution / changelog)

Summary

This PR fixes env-based boolean configuration for settings.json.

Previously, interpolated env values were always strings, which could trigger validation warnings for boolean settings (for example, ui.autoThemeSwitching). This change adds schema-aware coercion so "true"/"false" values are interpreted as booleans where appropriate.

Details

  • Resolve env vars, then normalize schema-typed boolean fields before validation.
  • Keep coercion limited to boolean settings defined in the schema.
  • Preserve existing behavior for string-only maps (for example, MCP server env values stay strings).
  • Add focused tests for both coercion and non-coercion paths.
  • Document the boolean casting behavior in the configuration reference.

Related Issues

Fixes #25573

How to Validate

  1. Add an env-based boolean setting in settings.json, for example:
    • "ui": { "autoThemeSwitching": "${GEMINI_AUTO_THEME:-true}" }
  2. Set GEMINI_AUTO_THEME to TRUE or FALSE.
  3. Run:
    • npm test -w @google/gemini-cli -- src/config/settings.test.ts
  4. Verify these tests pass:
    • should coerce env-resolved boolean setting values from strings
    • should not coerce env-resolved values in string-only map settings

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

Changed files

  • docs/reference/configuration.md (modified, +5/-3)
  • packages/cli/src/config/settings.test.ts (modified, +64/-0)
  • packages/cli/src/config/settings.ts (modified, +90/-5)
RAW_BUFFERClick to expand / collapse

What would you like to be added?

Hi, About this feature: https://geminicli.com/docs/reference/configuration/#environment-variables-and-env-files

Could you make it support casting the strings "true" and "false" to booleans?

Right now it says:

Error in: ui.autoThemeSwitching Expected boolean, received string

When I set this value:

"autoThemeSwitching": "${GEMINI_AUTO_THEME:-true}"

Why is this needed?

I want to set the autoThemeSwitching flag via environment variables. This is because Gemini CLI wrongly identifies my shell as light when it is actually dark. And I can't rely on a static value, such as setting autoThemeSwitching to false, because I have multiple VTEs, some dark and some light.

Additional context

No response

extent analysis

TL;DR

The issue can be resolved by modifying the configuration to properly cast environment variable strings to booleans.

Guidance

  • The error message indicates that the autoThemeSwitching value is expected to be a boolean, but a string is being received.
  • To fix this, the configuration needs to be updated to cast the environment variable string to a boolean value.
  • The user wants to set the autoThemeSwitching flag via environment variables to handle multiple VTEs with different themes.
  • The Gemini CLI documentation on environment variables and env files may need to be updated to support this use case.

Example

No code snippet is provided as the issue is related to configuration and environment variables.

Notes

The issue is specific to the Gemini CLI configuration and environment variables. The solution may involve updating the configuration to support boolean casting or using a different approach to set the autoThemeSwitching flag.

Recommendation

Apply workaround: The user can try using a different configuration approach, such as using a separate configuration file or a different environment variable syntax, to achieve the desired behavior.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

gemini-cli - ✅(Solved) Fix Support boolean types when configuring `settings.json` via environment variables [1 pull requests, 1 comments, 2 participants]