Skip to content

Conversation

@sapphi-red
Copy link
Contributor

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

@changeset-bot
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
Copy link
Member

@natemoo-re natemoo-re left a comment

Choose a reason for hiding this comment

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

Thanks so much for the fix!

@natemoo-re natemoo-re changed the base branch from main to v0 March 21, 2025 13:30
@natemoo-re natemoo-re changed the base branch from v0 to main March 21, 2025 13:30
@natemoo-re natemoo-re merged commit a36292b into bombshell-dev:main Mar 21, 2025
2 checks passed
@natemoo-re natemoo-re added the backport This PR should be cherry-picked onto v0 label Mar 21, 2025
natemoo-re pushed a commit that referenced this pull request Mar 30, 2025
@natemoo-re natemoo-re linked an issue Apr 8, 2025 that may be closed by this pull request
@sapphi-red sapphi-red deleted the fix/tty-initialization-error-on-windows branch April 17, 2025 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR should be cherry-picked onto v0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] ERR_TTY_INIT_FAILED on git bash (MINGW64)

3 participants