gemini-cli - 💡(How to fix) Fix Bug : Session exit after shell action execution over SSH/Remote Terminal [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#25828Fetched 2026-04-23 07:44:46
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Participants
Timeline (top)
labeled ×1

When running the Gemini CLI on a Raspberry Pi Zero 2 W, the session intermittently exits after a shell action is authorized. While the command executes successfully, the CLI often fails to return to the interactive prompt, instead dropping the user back to the system shell. This behavior is inconsistent—it occasionally works as expected, but fails frequently.

Root Cause

When running the Gemini CLI on a Raspberry Pi Zero 2 W, the session intermittently exits after a shell action is authorized. While the command executes successfully, the CLI often fails to return to the interactive prompt, instead dropping the user back to the system shell. This behavior is inconsistent—it occasionally works as expected, but fails frequently.

RAW_BUFFERClick to expand / collapse

Description

When running the Gemini CLI on a Raspberry Pi Zero 2 W, the session intermittently exits after a shell action is authorized. While the command executes successfully, the CLI often fails to return to the interactive prompt, instead dropping the user back to the system shell. This behavior is inconsistent—it occasionally works as expected, but fails frequently.

Environment

  • Device: Raspberry Pi Zero 2 W (512MB RAM)
  • OS: Raspberry Pi OS Lite (64-bit)
  • Node Version: v24.14.1
  • Connection Method: SSH (Windows CMD/PowerShell), Raspberry Pi Connect (Web-based)

Steps to Reproduce

  1. Connect to the Pi via SSH.
  2. Launch the CLI: gemini
  3. Trigger a shell tool (e.g., pip list or ls /dev/spi*).
  4. Select "1. Allow once" from the interactive menu.
  5. Observed Behavior: The command output prints to the terminal.
  6. The Intermittent Bug: - Fail Case: The Gemini process terminates immediately after the command output, returning to user@raspberrypi:~$.
    • Success Case: The Gemini prompt ? reappears, allowing further interaction.

Additional Context

  • Hardware Constraints: The issue is occurring on a Pi Zero 2 W. Given the limited 512MB RAM, this may be a resource exhaustion issue or a timing race condition during the TTY handoff between the child process and the ink UI.
  • PTY Status: enableInteractiveShell is enabled.
  • Inconsistency: There is no clear pattern to the failures, though it seems more prone to exiting when the command output is lengthy or the system is under higher load.

Hypothesis

There appears to be a race condition in the stdin/stdout handoff. On low-resource hardware like the Pi Zero 2, the parent Node.js process may be losing terminal focus or receiving an end-of-file (EOF) signal before the UI has a chance to re-initialize after the shell execution finishes.

extent analysis

TL;DR

Adjusting the resource allocation or implementing a delay after shell actions may help mitigate the intermittent exit issue with the Gemini CLI on the Raspberry Pi Zero 2 W.

Guidance

  • Investigate the system's resource utilization during the execution of shell actions to confirm if resource exhaustion is a contributing factor.
  • Consider adding a short delay after the shell action completes, before attempting to return to the interactive prompt, to mitigate potential race conditions.
  • Review the enableInteractiveShell configuration and its implications on the TTY handoff process to ensure it's optimized for low-resource environments.
  • Test the CLI with varying lengths of command output and system loads to better understand the conditions under which the failure occurs.

Example

No specific code snippet can be provided without altering the existing implementation, but a hypothetical solution might involve introducing a delay or a more robust handling of the TTY handoff.

Notes

The solution may require adjustments based on the specific implementation details of the Gemini CLI and the ink UI library, which are not fully provided in the issue description.

Recommendation

Apply a workaround, such as introducing a delay after shell actions, as the root cause seems related to resource constraints and race conditions rather than a straightforward version fix.

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