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

[Bug] ERR_TTY_INIT_FAILED on git bash (MINGW64) #192

Open
brc-dd opened this issue Apr 29, 2024 · 3 comments
Open

[Bug] ERR_TTY_INIT_FAILED on git bash (MINGW64) #192

brc-dd opened this issue Apr 29, 2024 · 3 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@brc-dd
Copy link

brc-dd commented Apr 29, 2024

Environment

  • OS: Windows
  • Node Version: v22.0.0
  • Package: @clack/prompts
  • Package Version: v0.7.0

Describe the bug

https://github.com/natemoo-re/clack/blob/45ee73bf33b25f9a8c7e1bb6117ccc165478bf4d/packages/core/src/prompts/prompt.ts#L82

This line throws ERR_TTY_INIT_FAILED when used inside terminals like Git Bash.

To Reproduce

You'll need a Windows machine (or VM, I'm using UTM on mac) with Git Bash installed. Then try running any project using clack. For example with VitePress:

mkdir foo
npm add -D vitepress
npx vitepress init

Or with Svelte:

npm create svelte@latest foo

Expected behavior

Work similar to other terminals or maybe a fallback strategy in case write stream can't be opened on stdin.

Additional Information

Downstream issues - vuejs/vitepress#3841, sveltejs/svelte#8595, https://stackoverflow.com/q/75750730/11613622,

@Dmytro-Shulha
Copy link

Having same problem when trying to run tests from within Git Bash:
image

@github-project-automation github-project-automation bot moved this to Needs triage in Triage Board Dec 29, 2024
@natemoo-re natemoo-re moved this from Needs triage to On deck in Triage Board Jan 4, 2025
@natemoo-re natemoo-re added the help wanted Extra attention is needed label Jan 4, 2025
@natemoo-re
Copy link
Member

Hey, thanks for opening an issue! I'm finally working through the backlog here.

Windows strikes again... I'll have to investigate what other libraries do to workaround this! All of Windows support is honestly pretty naive and it'd be great to do more feature detection in general.

@lilnasy
Copy link

lilnasy commented Jan 5, 2025

The root cause is the fact that the version of mintty terminal emulator included with git on windows is not interactive by default.

Image

Node.js contributor documentation makes a footnote of this:

On Windows, running Node.js in Windows terminal emulators like mintty requires the usage of winpty for the tty channels to work (e.g. winpty node.exe script.js). In "Git bash" if you call the node shell alias (node without the .exe extension), winpty is used automatically.

As they say, it is possible to make it the terminal behave as interactive with the winpty CLI also included with git on windows.
Image
...but the command being run is unfortunately only under the package manager's and the app's control (svelte, vitepress), not clack's.

  • As a user, you can use another terminal.
  • As a developer of an app dependent on clack, you might have some success by checking the environment and running a fork-exec with winpty.
  • Clack could provide a better error message when stdout is not interactive.

I'm not sure what the errors in @Dmytro-Shulha's screenshot are about: I would expect it to fail that way in a CI environment, but it is on Windows Terminal, which I haven't been able reproduce the issue with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
Status: On deck
Development

No branches or pull requests

4 participants