Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: uv_tty_init error on Windows #235

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sapphi-red
Copy link

This PR fixes the following error happening on Windows for non-tty terminals.

TTY initialization failed: uv_tty_init returned EBADF (bad file descriptor)

The error was happening this line.

const sink = new WriteStream(0);

It seems calling new tty.WriteStream with non-tty file descriptor throws the error above.

I changed tty.WriteStream with stream.Writable and set terminal: true option for readline.createInterface so that readline will treat stream.Writable as a terminal.

I first went with replacing new WriteStream(0) with isatty(0) ? new WriteStream(0) : fs.createWriteStream(null, { fd: 0 }). It worked locally, but that didn't pass the tests.

refs #192

Copy link

changeset-bot bot commented Feb 18, 2025

🦋 Changeset detected

Latest commit: 17a011c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@clack/core Patch
@clack/prompts Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Zamiell
Copy link

Zamiell commented Feb 22, 2025

@sapphi-red Thanks so much! I am trying out clack for the first time on Windows, using the built-in Git Bash for Windows that comes automatically when you install Git, and I was confronted with this error.

Here's hoping we can get this merged soon with a new release!

bluwy added a commit to vitejs/vite that referenced this pull request Feb 25, 2025
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.

2 participants