From 5b7b6fe608257381f522df5432d76e9fdf2bc144 Mon Sep 17 00:00:00 2001
From: Marat Boshernitsan <maratb@google.com>
Date: Fri, 18 Jul 2025 17:22:50 -0700
Subject: Automatically detect non-interactive environments and fall back to a
 manual, code-based authentication flow  (#4475)

---
 packages/cli/src/gemini.tsx | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

(limited to 'packages/cli/src/gemini.tsx')

diff --git a/packages/cli/src/gemini.tsx b/packages/cli/src/gemini.tsx
index 71e69952..f00dfd45 100644
--- a/packages/cli/src/gemini.tsx
+++ b/packages/cli/src/gemini.tsx
@@ -37,6 +37,7 @@ import {
   logUserPrompt,
   AuthType,
   getOauthClient,
+  shouldAttemptBrowserLaunch,
 } from '@google/gemini-cli-core';
 import { validateAuthMethod } from './config/auth.js';
 import { setMaxSizedBoxDebugging } from './ui/components/shared/MaxSizedBox.js';
@@ -184,7 +185,7 @@ export async function main() {
 
   if (
     settings.merged.selectedAuthType === AuthType.LOGIN_WITH_GOOGLE &&
-    config.getNoBrowser()
+    (config.getNoBrowser() || !shouldAttemptBrowserLaunch())
   ) {
     // Do oauth before app renders to make copying the link possible.
     await getOauthClient(settings.merged.selectedAuthType, config);
-- 
cgit v1.2.3

