Skip to content

Conversation

@ManojINaik
Copy link
Contributor

@ManojINaik ManojINaik commented Dec 29, 2025

On Windows, the pickTty() function attempted to open /dev/tty which doesn't exist, causing an ENOENT error ('C:\dev\tty'). This caused the CLI to crash when users ran the /copy command.

The fix adds a platform check to skip /dev/tty on Windows and fall back to stderr/stdout or clipboardy for clipboard operations.

Fixes #15648
Fixes #15567

Summary

Fix CLI crash on Windows when using /copy command. The pickTty() function attempted to open /dev/tty (Unix-only) which caused an unhandled ENOENT error on Windows.

Details

Root Cause: On Windows, Node.js interprets /dev/tty as C:\dev\tty, which doesn't exist. The fs.createWriteStream() call doesn't throw synchronously - it emits an async 'error' event that was unhandled.

Solution: Added process.platform !== 'win32' check before attempting /dev/tty. On Windows:

  • Falls back to stderr/stdout if TTY available (for SSH sessions)
  • Falls back to clipboardy library for native Windows clipboard

Files Changed:

  • packages/cli/src/ui/utils/commandUtils.ts - Added platform check in pickTty()
  • packages/cli/src/ui/utils/commandUtils.test.ts - Added 2 Windows-specific tests

Related Issues

Fixes #15648 - CLI crashes on Windows when using /copy (Error: ENOENT 'C:\dev\tty')
Fixes #15567 - [Bug] Windows crash when using /copy: Error: ENOENT: no such file or directory
Fixes #15660
Fixes #15667
Fixes #15920

How to Validate

  1. Run tests: cd packages/cli && npx vitest run src/ui/utils/commandUtils.test.ts
  2. Verify all 24 tests pass including:
    • skips /dev/tty on Windows and uses stderr fallback for OSC-52
    • uses clipboardy on native Windows without SSH/WSL
  3. On Windows: Run gemini, generate a response, run /copy, verify no crash and content is copied

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

@ManojINaik ManojINaik requested a review from a team as a code owner December 29, 2025 06:45
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @ManojINaik, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a critical bug that caused the CLI to crash on Windows when users attempted to use the /copy command. The issue stemmed from an attempt to access /dev/tty, a Unix-specific device, on Windows systems. The changes introduce a robust platform check, ensuring that the CLI gracefully handles clipboard operations on Windows by falling back to appropriate mechanisms like stderr/stdout for SSH sessions or the clipboardy library for native environments, thereby significantly improving the application's stability and user experience on the Windows platform.

Highlights

  • Windows Crash Fix: Prevented a CLI crash on Windows that occurred when using the /copy command, which was caused by an attempt to open /dev/tty.
  • Platform-Specific TTY Handling: Implemented a platform check (process.platform !== 'win32') in the pickTty() function to explicitly skip /dev/tty on Windows systems.
  • Clipboard Fallback Logic: Ensured that on Windows, the CLI now correctly falls back to stderr/stdout for OSC-52 in SSH sessions or utilizes the clipboardy library for native Windows clipboard operations.
  • New Test Cases: Added two new Windows-specific test cases to commandUtils.test.ts to validate the correct behavior of TTY and clipboard handling on the Windows platform.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request fixes a crash on Windows when using the /copy command by avoiding an attempt to access /dev/tty. The change is correct and includes relevant tests. My review includes two suggestions: one to improve test isolation to prevent flaky tests, and another to enhance the robustness of error handling for fs.createWriteStream on non-Windows platforms to prevent potential crashes, building upon the insight from the PR description.

On Windows, the pickTty() function attempted to open /dev/tty which
doesn't exist, causing an ENOENT error ('C:\dev\tty'). This caused
the CLI to crash when users ran the /copy command.

The fix adds a platform check to skip /dev/tty on Windows and
fall back to stderr/stdout or clipboardy for clipboard operations.

Fixes google-gemini#15648
Fixes google-gemini#15567
@ManojINaik ManojINaik force-pushed the fix/windows-copy-crash-clean branch from dfdd105 to 287de4c Compare December 29, 2025 06:52
Copy link
Collaborator

@jackwotherspoon jackwotherspoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits

@jackwotherspoon
Copy link
Collaborator

I have verified this fix works on my Windows machine. Once builds pass will merge.

Thanks for this @ManojINaik 👏

@jackwotherspoon jackwotherspoon changed the title fix(cli): prevent /copy crash on Windows by skipping /dev/tty (#15648, #15567) fix: prevent /copy crash on Windows by skipping /dev/tty (#15648, #15567) Jan 5, 2026
@jackwotherspoon jackwotherspoon changed the title fix: prevent /copy crash on Windows by skipping /dev/tty (#15648, #15567) fix: prevent /copy crash on Windows by skipping /dev/tty Jan 5, 2026
@jackwotherspoon jackwotherspoon added this pull request to the merge queue Jan 5, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 5, 2026
@jackwotherspoon jackwotherspoon added this pull request to the merge queue Jan 5, 2026
Merged via the queue into google-gemini:main with commit 2da911e Jan 5, 2026
38 of 46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants