gemini-cli - 💡(How to fix) Fix [BUG] PTY Master Device Exhaustion (ENXIO) on macOS after prolonged usage in YOLO mode [3 comments, 3 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#25583Fetched 2026-04-18 05:57:43
View on GitHub
Comments
3
Participants
3
Timeline
10
Reactions
0
Author
Timeline (top)
labeled ×4commented ×3unlabeled ×2cross-referenced ×1

After running gemini-cli (v0.38.1) for an extended period (weeks) with --approval-mode yolo, the system eventually hits the macOS PTY limit (kern.tty.ptmx_max = 511), preventing any new terminal sessions from opening system-wide with the error: Device not configured.

Error Message

After running gemini-cli (v0.38.1) for an extended period (weeks) with --approval-mode yolo, the system eventually hits the macOS PTY limit (kern.tty.ptmx_max = 511), preventing any new terminal sessions from opening system-wide with the error: Device not configured.

Root Cause

After running gemini-cli (v0.38.1) for an extended period (weeks) with --approval-mode yolo, the system eventually hits the macOS PTY limit (kern.tty.ptmx_max = 511), preventing any new terminal sessions from opening system-wide with the error: Device not configured.

RAW_BUFFERClick to expand / collapse

Description

After running gemini-cli (v0.38.1) for an extended period (weeks) with --approval-mode yolo, the system eventually hits the macOS PTY limit (kern.tty.ptmx_max = 511), preventing any new terminal sessions from opening system-wide with the error: Device not configured.

Diagnostic Evidence

  • System Limit: sysctl kern.tty.ptmx_max → 511
  • Current Usage: lsof | grep "/dev/ptmx" | wc -l → 511
  • Top Consumer: PID 11595 (node .../bin/gemini --approval-mode yolo) is holding 230 PTY master descriptors. Other orphaned Gemini instances are holding the remainder.
  • Process State: sample of the process shows it is healthy and sitting in a uv__io_poll wait state, but it has failed to release /dev/ptmx descriptors for sub-agents or tool calls (e.g., ck).
  • Uptime: The leaking processes have uptimes ranging from 1 to 17 days.

Steps to Reproduce

  1. Run Gemini CLI in a persistent session (e.g., within tmux).
  2. Use --approval-mode yolo.
  3. Perform numerous tasks that invoke sub-agents or external search tools over several days.
  4. Observe the PTY count increasing via lsof without ever decreasing.

Environment

  • OS: macOS 15.7.2 (ARM64)
  • Node Version: 22.21.1
  • Gemini CLI Version: 0.38.1

Related Issues

Likely related to #22814 (File descriptor leak in ShellExecutionService) and #22001 (Terminal Instance Resource Retention).

extent analysis

TL;DR

The issue can be mitigated by terminating the long-running gemini-cli process and restarting it periodically to release the accumulated PTY descriptors.

Guidance

  • Investigate the --approval-mode yolo configuration to understand its impact on PTY descriptor management, as it may be contributing to the leak.
  • Monitor the PTY count using lsof | grep "/dev/ptmx" | wc -l to detect when the system is approaching the limit.
  • Consider implementing a periodic restart of the gemini-cli process to prevent the descriptor leak from accumulating over time.
  • Review the related issues #22814 and #22001 to see if there are any known fixes or workarounds for the file descriptor leak in ShellExecutionService and Terminal Instance Resource Retention.

Example

No code snippet is provided as the issue is related to a specific configuration and system resource management.

Notes

The provided guidance is based on the assumption that the gemini-cli process is not properly releasing PTY descriptors, leading to the system-wide limit being reached. The actual root cause may be more complex and require further investigation.

Recommendation

Apply workaround: Implement a periodic restart of the gemini-cli process to prevent the descriptor leak from accumulating over time. This is recommended because it provides a temporary solution to mitigate the issue until a more permanent fix is available.

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