Skip to content

Fix /copy command crash on Windows due to /dev/tty handling - #1

Draft
admannon with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-issue-15193
Draft

Fix /copy command crash on Windows due to /dev/tty handling#1
admannon with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-issue-15193

Conversation

Copilot AI commented Dec 23, 2025

Copy link
Copy Markdown

Summary

The /copy command crashes on Windows attempting to open /dev/tty, a Unix-specific device file that doesn't exist on Windows. Similar permission errors occur on macOS.

Details

Root cause: fs.createWriteStream('/dev/tty') returns a stream object synchronously but emits errors asynchronously, bypassing the try-catch block.

Changes:

  • Skip /dev/tty entirely on Windows
  • Use fs.accessSync() to verify writability before creating stream on Unix platforms
  • Maintain fallback chain: /dev/tty → stderr → stdout → clipboardy
// Before: crashes on Windows
const devTty = fs.createWriteStream('/dev/tty');

// After: platform-aware with sync check
if (process.platform !== 'win32') {
  fs.accessSync('/dev/tty', fs.constants.W_OK);
  const devTty = fs.createWriteStream('/dev/tty');
}

Related Issues

Fixes google-gemini#15193

How to Validate

Windows:

# In SSH session with stderr as TTY
gemini
> /copy
# Should write OSC-52 to stderr without crash

# Without TTY
gemini
> /copy
# Should use clipboardy fallback without crash

macOS/Linux:

# With accessible /dev/tty
gemini
> /copy
# Should use /dev/tty for OSC-52

# Simulate inaccessible /dev/tty
chmod 000 /dev/tty 2>/dev/null || true
gemini
> /copy
# Should fall back to stderr/stdout without crash

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/google-gemini/gemini-cli/issues/15193
    • Triggering command: /usr/bin/curl curl -s REDACTED (http block)
  • marketplace.visualstudio.com
    • Triggering command: /usr/local/bin/node /usr/local/bin/node --conditions node --conditions development /home/REDACTED/work/gemini-cli/gemini-cli/node_modules/tinypool/dist/entry/process.js --conditions /usr/bin/grep /home/REDACTED/worsort uniq /usr/bin/cat grep core�� d" | sort | uniq | wc -l cat ode in/sh /bin/sh /usr/bin/sort ode (dns block)
  • play.googleapis.com
    • Triggering command: /usr/local/bin/node /usr/local/bin/node --conditions node --conditions development /home/REDACTED/work/gemini-cli/gemini-cli/node_modules/tinypool/dist/entry/process.js node /bin/sh run (dns block)
  • test-server
    • Triggering command: /usr/local/bin/node /usr/local/bin/node --conditions node --conditions development /home/REDACTED/work/gemini-cli/gemini-cli/node_modules/tinypool/dist/entry/process.js sort /bin/sh p/bin/sh eck /usr/local/bin/nDROP /bin/sh -c d" | sort | uniq | wc -l /usr/local/bin/node /usr/bin/wc node --conditions /bin/sh wc (dns block)
  • test-server.com
    • Triggering command: /usr/local/bin/node /usr/local/bin/node --conditions node --conditions development /home/REDACTED/work/gemini-cli/gemini-cli/node_modules/tinypool/dist/entry/process.js sort /bin/sh p/bin/sh eck /usr/local/bin/nDROP /bin/sh -c d" | sort | uniq | wc -l /usr/local/bin/node /usr/bin/wc node --conditions /bin/sh wc (dns block)
  • wombat-dressing-room.appspot.com
    • Triggering command: /usr/local/bin/node node /usr/local/bin/npm install (dns block)
    • Triggering command: /usr/local/bin/node node /usr/local/bin/npm ci sh -c ges/cli/src/ui/utils/commandUtils.test.ts (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

แก้ google-gemini#15193 หน่อย


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: admannon <1027194+admannon@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issue 15193 in gemini-cli Fix /copy command crash on Windows due to /dev/tty handling Dec 23, 2025
Copilot AI requested a review from admannon December 23, 2025 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: /copy command crashes due to /dev/tty path handling error

2 participants