gemini-cli - 💡(How to fix) Fix Crash: `ioctl(2) failed, EBADF` in `node-pty` during PTY resize on macOS

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…

Error Message

While using Gemini CLI on macOS, the application crashes with the following PTY-related error: ERROR ioctl(2) failed, EBADF Instead of throwing a fatal error, the CLI should gracefully handle invalid PTY/file descriptor states internally.

RAW_BUFFERClick to expand / collapse

What happened?

While using Gemini CLI on macOS, the application crashes with the following PTY-related error:

ERROR ioctl(2) failed, EBADF

The stack trace points to:

@lydell/node-pty/unixTerminal.js:243 pty.resize(this._fd, cols, rows);

This results in an unexpected critical crash and the CLI exits immediately.

The issue appears to happen during PTY resize handling.

What did you expect to happen?

Gemini CLI should continue running normally without crashing during terminal resize or PTY updates.

Instead of throwing a fatal error, the CLI should gracefully handle invalid PTY/file descriptor states internally.

Client information

Platform: macOS

Installation method:

npm install -g @google/gemini-cli

Node.js installed via Homebrew:

/opt/homebrew/lib/node_modules/@google/gemini-cli

Gemini CLI was installed globally.

Login information

Logged in using Google Account authentication.

Anything else we need to know?

This seems related to PTY/file descriptor handling inside node-pty on macOS.

Possible trigger scenarios:

terminal window resize, PTY/session restoration, invalid or already-closed file descriptor during resize operation.

Failing line:

pty.resize(this._fd, cols, rows);

A file descriptor validity check before resize may help prevent the crash.

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