Bug Description
Gemini CLI OAuth is broken on Windows when gemini-cli is installed via nvm. Two independent bugs prevent setup from completing.
Bug 1: extractGeminiCliCredentials finds wrong oauth2.js
On Windows with nvm, gemini.cmd resolves (via realpathSync) to e.g. C:\Users\<user>\AppData\Local\nvm\v24.1.0\gemini.cmd. The first candidate path becomes the nvm root directory.
findFile with depth 10 then finds discord-api-types/payloads/v10/oauth2.js — a completely unrelated file. The code tries to extract credentials from this file, fails, and surfaces:
Error: Gemini CLI not found. Install it first: brew install gemini-cli
Bug 2: resolvePlatform returns "WINDOWS" which Google API rejects
resolvePlatform() returns "WINDOWS" on win32, but Google's loadCodeAssist API does not accept it as a valid Platform enum value. All three endpoints respond with 400 INVALID_ARGUMENT.
Steps to Reproduce
- Install nvm for Windows (nvm4w)
- Install Node.js via nvm (e.g.
nvm install 24.1.0)
- Install gemini-cli globally (
npm i -g @anthropic-ai/gemini-cli or equivalent)
- Attempt to use Gemini CLI OAuth in openclaw
Expected Behavior
OAuth setup completes successfully and Gemini CLI works on Windows.
Actual Behavior
- Bug 1: Wrong
oauth2.js file is found, credential extraction fails
- Bug 2: Google API rejects the
"WINDOWS" platform value with 400 error
Fix
PR #40729 addresses both issues.
Bug Description
Gemini CLI OAuth is broken on Windows when
gemini-cliis installed via nvm. Two independent bugs prevent setup from completing.Bug 1:
extractGeminiCliCredentialsfinds wrongoauth2.jsOn Windows with nvm,
gemini.cmdresolves (viarealpathSync) to e.g.C:\Users\<user>\AppData\Local\nvm\v24.1.0\gemini.cmd. The first candidate path becomes the nvm root directory.findFilewith depth 10 then findsdiscord-api-types/payloads/v10/oauth2.js— a completely unrelated file. The code tries to extract credentials from this file, fails, and surfaces:Bug 2:
resolvePlatformreturns"WINDOWS"which Google API rejectsresolvePlatform()returns"WINDOWS"onwin32, but Google'sloadCodeAssistAPI does not accept it as a validPlatformenum value. All three endpoints respond with400 INVALID_ARGUMENT.Steps to Reproduce
nvm install 24.1.0)npm i -g @anthropic-ai/gemini-clior equivalent)Expected Behavior
OAuth setup completes successfully and Gemini CLI works on Windows.
Actual Behavior
oauth2.jsfile is found, credential extraction fails"WINDOWS"platform value with 400 errorFix
PR #40729 addresses both issues.