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

yarn fails with stdin is not a tty #2998

Closed
mikew opened this issue Mar 27, 2017 · 34 comments
Closed

yarn fails with stdin is not a tty #2998

mikew opened this issue Mar 27, 2017 · 34 comments

Comments

@mikew
Copy link
Contributor

mikew commented Mar 27, 2017

Do you want to request a feature or report a bug?
bug

What is the current behavior?
yarn exits with the error stdin is not a tty

If the current behavior is a bug, please provide the steps to reproduce.
https://github.com/mikew/yarn-ci-testcase

bash -c 'yarn install'

What is the expected behavior?
Yarn should install packages

Please mention your node.js, yarn and operating system version.
yarn 0.21.3
node 7.7.4
Windows 10

I should note I'm experiencing this behaviour in Gitlab CI Runner. Using bash -c 'npm install' does work, however.

@michielboekhoff
Copy link

Is anyone working on this issue? Otherwise I might have a look at it.

@michielboekhoff
Copy link

@mikew Hey, after having looked for a bit, I'm getting this error on a Windows 7 box because of winpty. Is your GitLab CI runner maybe also running Windows?

@mikew
Copy link
Contributor Author

mikew commented Mar 31, 2017

The one that's giving me this issue is running Windows 10, yes.

@michielboekhoff
Copy link

@mikew I don't believe the issue to be with Yarn then, but instead with winpty. Since I'm also running into this, I'd be willing to have a look at winpty, to see if this can be resolved, but it'd have to happen after the weekend.

@Daniel15
Copy link
Member

Daniel15 commented Apr 2, 2017

Probably closely related to #2591 ("stdout is not a tty")

It does seem like winpty is causing something strange to happen, as it only throws the error when using winpty (which the yarn shell script does do):

@mikew
Copy link
Contributor Author

mikew commented Apr 2, 2017

Interesting. This does work:

winpty -Xallow-non-tty node ./yarn.js --version | cat

@Daniel15
Copy link
Member

Daniel15 commented Apr 2, 2017

Oh cool! Would you like to send a pull request adding the -Xallow-non-tty option to the Yarn shell script? The winpty invocation is here: https://github.com/yarnpkg/yarn/blob/master/bin/yarn#L19

@mikew
Copy link
Contributor Author

mikew commented Apr 3, 2017

Oh, it didn't actually work with yarn install:

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
Assertion failed!

Program: C:\Program Files\Git\usr\bin\winpty.exe
File: src/libwinpty/winpty.cc, Line 924

Expression: ASSERT_CONDITION("wp != nullptr && cols > 0 && rows > 0")
√ Rebuild Complete

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
Assertion failed!

Program: C:\Program Files\Git\usr\bin\winpty.exe
File: src/libwinpty/winpty.cc, Line 924

Expression: ASSERT_CONDITION("wp != nullptr && cols > 0 && rows > 0")

@mikew
Copy link
Contributor Author

mikew commented Apr 3, 2017

In fact, disabling the use_winpty logic actually lets my build pass.

@michielboekhoff
Copy link

I can verify that removing the use_winpty logic works, on Windows 7. Is anyone aware of any consequences removing that could have?

@mikew
Copy link
Contributor Author

mikew commented Apr 7, 2017

Is it just for Windows Command Prompt support? If so, wouldn't it make more sense to move it to yarn.cmd?

@Daniel15
Copy link
Member

Daniel15 commented Apr 7, 2017

The use_winpty logic was added as a fix to #743, in #2230. If you remove that logic, you should ensure that the original bug does not come back

Is it just for Windows Command Prompt support?

@mikew - No, it's only required for MinGW/Msys. Regular command prompt is fine and doesn't need it.

@mikew
Copy link
Contributor Author

mikew commented Apr 7, 2017

Are there test cases for this?

Because git-bash ...

screen shot 2017-04-07 at 2 14 35 pm

... cmd ...

screen shot 2017-04-07 at 2 14 45 pm

... and powershell ...

screen shot 2017-04-07 at 2 16 30 pm

... all seem unaffected.

@Daniel15
Copy link
Member

Daniel15 commented Apr 7, 2017

Interesting... There definitely used to be an issue (see #743) but maybe it no longer occurs? @thetrompf @lewiswalsh @jdalton what do you think?

@mikew
Copy link
Contributor Author

mikew commented Apr 22, 2017

Any thoughts on changing the flag to an environment variable like YARN_FORCE_WINPTY?

@Daniel15
Copy link
Member

Hmm, that might work. Alternatively, it's possible that there used to be a bug with Mingw or something, that's not a problem any more? I'm not sure.

@mikew
Copy link
Contributor Author

mikew commented Apr 24, 2017

I'm guessing you're correct, it just feels safer to still allow the flag somewhere.

@Daniel15
Copy link
Member

Sure, a flag sounds reasonable! Feel free to send a pull request - Should be pretty straightforward 😃

@mikew
Copy link
Contributor Author

mikew commented Apr 24, 2017

Done!

@luchillo17
Copy link

luchillo17 commented Oct 27, 2017

When will this be available? i have 1.2.1 installed but in Babun it still happens.

@thetrompf
Copy link
Contributor

what is babun? The issue is very circumstantial, what is your git bash version, what is your winpty version?

@luchillo17
Copy link

Ok, Babun is another terminal program for windows based on cygwin, idk how to look the winpty version.

@thetrompf
Copy link
Contributor

Run: winpty --version

@luchillo17
Copy link

winpty --version gives 0.4.3.

@vehsakul
Copy link

vehsakul commented Dec 1, 2017

Have the same behavior with bash -c 'yarn install &'. Want to watch for something in background. Any ideas?

@luchillo17
Copy link

@vehsakul What's the & for?

@vehsakul
Copy link

vehsakul commented Dec 1, 2017

@luchillo17 & starts command in background. I want to run some task that never returns inside a script using yarn run.

@luchillo17
Copy link

Oh i see, so like a file watcher or something like that started from yarn, right? to be honest that's very specific, is that command supposed to run in prod env? otherwise i can't think why would you want such a task in dev env, because if you want to stop it you would have to kill the process.

@thetrompf
Copy link
Contributor

thetrompf commented Dec 3, 2017 via email

@vehsakul
Copy link

vehsakul commented Dec 3, 2017

@thetrompf Yes, it does.

@vehsakul
Copy link

vehsakul commented Dec 3, 2017

@luchillo17 Right. It is very specific dev env thing. I've just considered yarn run as a convinient way to run commands without going to node_modules. Of course, tasks declared in package.json are different kind of stuff.

@hach-que
Copy link

hach-que commented Dec 13, 2017

I'm getting this just running "yarn" in a shell script, inside Git Bash. It's very consistent for me to replicate, and the invocation of winpty is indeed the cause as shown with this output:

June@JUNE-LAPTOP MINGW64 ~/Documents/Projects/... (js-upgrade)
$ winpty echo "test"
test

June@JUNE-LAPTOP MINGW64 ~/Documents/Projects/... (js-upgrade)
$ winpty echo "test" </dev/null
stdin is not a tty

Can we get an option like YARN_FORCE_WINPTY=0 yarn that will prevent winpty from being used (in this case, yarn is being used non-interactively in a script)?

Right now a workaround that works is:

command_exists() {
  command -v "$1" >/dev/null 2>&1;
}
if command_exists winpty && test -t 1; then
  # workaround yarn bug on Windows, see https://github.com/yarnpkg/yarn/issues/2998
  yarn --non-interactive </dev/tty
else
  yarn --non-interactive
fi

@theodorejb
Copy link

I kept getting this error when trying to run ./scripts/build-packages-dist.sh to build Angular on Windows 10. I was finally able to make the error go away by editing "C:\Program Files (x86)\Yarn\bin\yarn", commenting out the line winpty node "$basedir/yarn.js" "$@", and replacing it with the line in the else block below it (exec node "$basedir/yarn.js" "$@").

@cupid20103
Copy link

https://github.com/orgs/community/discussions/57981
please check this and guide me.

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

No branches or pull requests

10 participants