gemini-cli - 💡(How to fix) Fix WSL2: Cascade of critical bugs — OAuth session loss, hook schema breaking change (v0.39.1), EPIPE crashes, and untrusted workspace prompt blocking --yolo mode [3 comments, 1 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#26111Fetched 2026-04-29 06:35:52
View on GitHub
Comments
3
Participants
1
Timeline
9
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×5commented ×3labeled ×1

After weeks of production use of gemini-cli in WSL2 for autonomous agentic workflows (--yolo mode), we encountered a cascading series of bugs that collectively make the CLI unreliable for WSL2 development. Each fix reveals the next. This documents 5 confirmed bugs.


Error Message

Symptom: Error in: hooks.AfterAgent[0] Expected object, received string on every startup. No auto-migration, no docs update, error message doesn't show correct format. Hooks are silently discarded via debugLogger.warn (invisible to user). Symptom: Error: write EPIPE at writeToStdout — CLI crashes after every agent turn.

Root Cause

Root cause:

  • ~/.gemini/google_accounts.json shows "active": null after silent token drop
  • ~/.gemini/projects.json accumulated corrupt entry "/mnt/c": "c" from a session launched from Windows-mounted path — binding workspace to wrong GCP project

Code Example

"hooks": { "SessionStart": ["echo 'hello'"] }

---

"hooks": { "SessionStart": [{ "hooks": [{ "type": "command", "command": "echo 'hello'" }] }] }
RAW_BUFFERClick to expand / collapse

Environment

  • OS: Windows 11 with WSL2 Ubuntu 24.04
  • Node.js: v22.17.0
  • Gemini CLI version: v0.39.1 (npm global install)
  • Auth mode: oauth-personal (Google One AI Ultra subscription)
  • Shell: bash (WSL2)

Summary

After weeks of production use of gemini-cli in WSL2 for autonomous agentic workflows (--yolo mode), we encountered a cascading series of bugs that collectively make the CLI unreliable for WSL2 development. Each fix reveals the next. This documents 5 confirmed bugs.


Bug 1: OAuth Session Silently Invalidates

Symptom: Failed to sign in: Cloud Code Private API not enabled drops into interactive auth menu, blocking automation.

Root cause:

  • ~/.gemini/google_accounts.json shows "active": null after silent token drop
  • ~/.gemini/projects.json accumulated corrupt entry "/mnt/c": "c" from a session launched from Windows-mounted path — binding workspace to wrong GCP project

Fix: Background token refresh + prune stale projects.json + gemini auth reset command


Bug 2: Hook Schema Silent Breaking Change in v0.39.1

Symptom: Error in: hooks.AfterAgent[0] Expected object, received string on every startup.

Root cause (confirmed by reading bundle source chunk-WFCK2Z32.js):

Old valid format (now silently discarded):

"hooks": { "SessionStart": ["echo 'hello'"] }

New required Zod schema:

"hooks": { "SessionStart": [{ "hooks": [{ "type": "command", "command": "echo 'hello'" }] }] }

No auto-migration, no docs update, error message doesn't show correct format. Hooks are silently discarded via debugLogger.warn (invisible to user).


Bug 3: EPIPE Crash on AfterAgent Hook

Symptom: Error: write EPIPE at writeToStdout — CLI crashes after every agent turn.

Even nohup ... >/dev/null 2>&1 & doesn't prevent it. Hook subprocess inherits parent stdout during teardown.

Fix: Execute AfterAgent hooks in fully detached subprocess (new process group).


Bug 4: Untrusted Workspace Warning Blocks --yolo Mode

Interactive trust prompt appears even with --yolo flag. security.folderTrust.enabled: false does not suppress it. Fundamental regression for YOLO-mode users.


Bug 5: /mnt/c/ Path Corrupts projects.json

Launching CLI from Windows-mounted path creates stale "/mnt/c": "c" in projects.json that causes Cloud Code API errors in future sessions.


Comparative Observation

Running Claude Sonnet 4.6 in the identical WSL2 environment with identical hooks/configs produces zero warnings, zero EPIPE crashes, zero session loss, and consistent YOLO-mode automation. This isolates the issues to Gemini CLI's WSL2 integration layer specifically.

extent analysis

TL;DR

To address the reliability issues with gemini-cli in WSL2, apply fixes for each bug, including background token refresh, pruning stale projects.json, updating hook formats, executing AfterAgent hooks in detached subprocesses, and resolving the untrusted workspace warning.

Guidance

  • Bug 1 Fix: Run gemini auth reset and prune stale entries from ~/.gemini/projects.json to resolve OAuth session invalidation.
  • Bug 2 Fix: Update hook formats to match the new Zod schema, ensuring each hook is an object with a type and command.
  • Bug 3 Fix: Modify the execution of AfterAgent hooks to run in a fully detached subprocess to prevent EPIPE crashes.
  • Bug 4 Mitigation: Investigate why security.folderTrust.enabled: false does not suppress the untrusted workspace warning in --yolo mode.
  • Bug 5 Fix: Avoid launching the CLI from Windows-mounted paths to prevent corruption of projects.json.

Example

// Updated hook format
"hooks": {
  "SessionStart": [
    {
      "type": "command",
      "command": "echo 'hello'"
    }
  ]
}

Notes

These fixes are specific to the reported bugs and may not address all issues with gemini-cli in WSL2. Testing each fix in isolation can help verify their effectiveness.

Recommendation

Apply the workarounds for each bug, as there is no clear indication of a fixed version that addresses all these issues. This approach allows for targeted fixes without waiting for a comprehensive update.

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 - 💡(How to fix) Fix WSL2: Cascade of critical bugs — OAuth session loss, hook schema breaking change (v0.39.1), EPIPE crashes, and untrusted workspace prompt blocking --yolo mode [3 comments, 1 participants]