google-gemini / google-gemini/gemini-cli

[BUG] PTY Master Device Exhaustion (ENXIO) on macOS after prolonged usage in YOLO mode

Open
#25,583 6 comments 0 reactions 0 assignees View on GitHub
🔒 maintainer only area/core effort/large kind/bug priority/p1 status/manual-triage type/bug
Dominant language
TypeScript
Stars
107k
Forks
14.6k
Avg merge
2d 3h
Merged PRs (30d)
45

Description

### 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).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.