Under Git Bash on Windows when entering 'yarn init' I get the following error:
error Can't answer a question unless a user TTY
at ConsoleReporter.question (C:\Program Files (x86)\Yarn\lib\reporters\console\console-reporter.js:189:29)
at Object.
at next (native)
at step (C:\Program Files (x86)\Yarn\node_modules\babel-runtime\helpersasyncToGenerator.js:17:30)
at C:\Program Files (x86)\Yarn\node_modules\babel-runtime\helpersasyncToGenerator.js:28:20
at run (C:\Program Files (x86)\Yarn\node_modules\core-js\library\modules\es6.promise.js:87:22)
at C:\Program Files (x86)\Yarn\node_modules\core-js\library\modules\es6.promise.js:100:28
at flush (C:\Program Files (x86)\Yarn\node_modules\core-js\library\modules_microtask.js:18:9)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
Other yarn commands seem to work as expected.
Yarn v0.15.1
Node v6.0.0
Windows 10 Pro 1607
Seems like this is an issue with Cygwin and MinGW in that they're not 'proper' TTYs: https://github.com/nodejs/node/issues/3006
I don't think we can fix this at our end.
Well, one thing you could do would be to remove the check ;)
In all seriousness though. It is my understanding that the check is in place because you're trying to make sure that the I/O scenario that is about to happen will work. Does that check actually achieve this? Will the scenario actually fail in MinGW? If not, then a different check should be performed or it should be omitted completely IMHO.
My understanding is that the check is to stop the process hanging indefinitely when not using a TTY (for example, if running as part of a build process that pipes stdin and stdout). In theory, if there's no TTY, there's no way to accept input. May be the check should "if it's a TTY or if it's MinGW" to handle this case specifically? I think that'd fail if you try to pipe the output to a file when running under MinGW though (it'd hang).
FWIW the yarn master branch works with
npm init
works in Git Bash, Cygwin, WSL, & MINGW32.
Yeah, I just noticed that npm init
is fine. Sounds like we should take a look at how npm is handling it 馃槃
Sounds like we should take a look at how npm is handling it
They're simply not enforcing isTTY
.
Ahh, that's an interesting approach @oliversalzburg. I guess it means trying to run it in a script would result in the script "freezing" as it sits waiting for user input. Not ideal 馃槙
Maybe we could do that just for Git Bash and Cygwin - Only check isTTY on platforms that properly support it
So on the one side you have the users who, for some reason, try to run a command that requires user interaction in a script, which will now fail loudly and would otherwise fail silently and on the other side you have everyone who uses a somewhat popular terminal on Windows and is unable to use the command.
I really don't see why this is a hard choice or why it would need even more complicated terminal detection code to solve. The check is counter productive and should be removed. Slapping more prone-to-error code on top is not the solution.
That being said, I really don't care one way or the other, as there are other terminal emulators that run Git Bash which are not affected by this "problem". I would suggest that everyone who runs into this should have a look at ConEmu.
I also face this issue, so I run node -p -e "Boolean(process.stdout.isTTY)"
on git-bash as well as on windows cmd. Both return true
, which does not fit to the behavior of git-bash and cmd as discussed here, right? Or is there anything I misunderstood regarding the isTTY discussion?
If my assumption is right, this will point the finger again to Yarn.
Yarn version:
0.16.1
Node version:
4.4.5
Platform:
Win7 x64
Trace:
Error: Can't answer a question unless a user TTY
at ConsoleReporter.question (C:\Program Files (x86)\Yarn\lib\reporters\console\console-reporter.js:186:29)```
btw. same for nodejs 6.9.1
How is this going ?
Still working on this ? I'm facing this issue at the moment.
Hope this will be fixed soon.
I really don't get why it fails, yarn uses the "proper" way for testing this in https://github.com/yarnpkg/yarn/blob/7fe2e53a59d5c5d256459854dd7ad4d4ff874682/src/reporters/console/console-reporter.js#L173
by testing for process.stdout.isTTY
I'm using minTTY
which is bundled in Git for Windows
along side with Git bash
as well.
Node: v7.2.1
Yarn: v0.17.10
bkc@DESKTOP-NNSLT74 ~ $ node
> process.stdout.isTTY
true
>
(To exit, press ^C again or type .exit)
>
bkc@DESKTOP-NNSLT74 ~ $ cd workspace/ts-test/
bkc@DESKTOP-NNSLT74 ~/workspace/ts-test (master) $ yarn init
yarn init v0.17.10
error An unexpected error occurred: "Can't answer a question unless a user TTY".
info If you think this is a bug, please open a bug report with the information provided in "C:\\Users\\bkc\\workspace\\ts-test\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/init for documentation about this command.
bkc@DESKTOP-NNSLT74 ~/workspace/ts-test (master) $
Interestingly enough, if I install yarn as a dependency, to a project
yarn add yarn
and in invoke yarn via node and yarn.js it works fine.
node ./node_modules/yarn/bin/yarn.js init
yarn init v0.17.10
question name (yarn-test):
So it must have something to do with the native windows version?
Now it gets really weird, if I omit the node
part, and try to invoke
./node_modules/yarn/bin/yarn.js init
as an executable, it fails.
@thetrompf
So it must have something to do with the native windows version?
It's possible - Running "yarn" on Windows actually goes through either a batch file (when using a regular terminal like cmd.exe, Cmder, etc) or a shell script (when using something Bash-based like MinGW, Cygwin, etc). If you installed to the default location, it's at C:\Program Files (x86)\Yarn\bin\yarn.cmd
.
I fixed this by updating my git for windows to the latest version, it looks to be a problem with winpty.exe I also updated to the latest nightly version of yarn v0.20.0 as there was a patch concerning this applied in version 0.19.
node.js - v6.9.4 | yarn - v0.20.0-20170117.1018 | git for windows - 2.11.0.3 with MinGW teminal
I second with ArtistsTechGuy, upgrading to latest versions solved the issue.
Even upgrading Git to the latest version, it fails for me:
yarn init (yarn 0.24.5)
error An unexpected error occurred: "Can't answer a question unless a user TTY".
Cygwin's mintty returns false to node -p -e "Boolean(process.stdout.isTTY)"
.
I wonder if this stalls compound scripts such as "build": "yarn run clean && yarn cover"
. I see a process tree with the last command stuck in the destructor of node.exe's v8::Unlocker, with our clean script defined as "clean": "rimraf ./reports"
,
..node.exe ..yarn.js run build
..cmd.exe /d /s /c yarn run clean && yarn cover
node ..yarn.js run clean
I got the same error as @astudio8
$ yarn init
yarn init v0.24.5
error An unexpected error occurred: "Can't answer a question unless a user TTY".
info If you think this is a bug, please open a bug report with the information provided in "C:\\projects_personal\\react\\hyperscript-helpers-elm-like\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/init for documentation about this command.
$ git version
git version 2.13.0.windows.1
Windows 10
Git Bash error ..
$ yarn init
yarn init v0.24.6
error An unexpected error occurred: "Can't answer a question unless a user TTY".
$ git --version 2.13.1.windows.2
Good thing is, Windows PowerShell works without errors.
Is there any solution now?
I has been waiting for this to fix since a long time ago.
I think I have a solution. Add the following to your .bashrc file:
alias yarn='node "C:\Program Files (x86)\Yarn\bin\yarn.js"'
Running yarn init
should work now, maybe, hopefully... It works on my PC, at least.
I had the same problem.
When use Git Bash under console emulator ConEmu, this problem don't arise.
As previously stated in this thread, the problem is TTY handling in git-bash. So successfully ran 'yarn upgrade-interactive' using 'winpty yarn.CMD upgrade-interactive' and latter aliased yarn to 'winpty yarn.CMD' in .bashrc
I think it's worth noting that sometimes you want winpty and sometimes you dont. Though in 90% cases you're safe with it prefixed.
From what I can tell it boils down to:
Action | Such as? | Prefix with winpty?
--------|----------------------| ----
Using yarn
inside a pipe? | yarn.cmd --version \| cat
| No
Using an interactive yarn
command? | yarn.cmd init
| Yes
Doing something outside a pipe and not interactive? | yarn.cmd install
yarn.cmd add
| Doesn't matter
$ winpty yarn.cmd init
yarn init v1.0.2
error An unexpected error occurred: "canceled".
info If you think this is a bug, please open a bug report with the information provided in
$ yarn.cmd init
yarn init v1.0.2
error An unexpected error occurred: "Can't answer a question unless a user TTY".
info If you think this is a bug, please open a bug report with the information provided in
$ winpty yarn.cmd --version
1.0.2
$ winpty yarn.cmd --version |cat
stdout is not a tty
$ yarn.cmd --version | cat
1.0.2
@jmathew see my pull request, which tries to fix this #4577
@thetrompf I haven't tested it but the script change makes sense. Thanks!
To me this was a pretty silly issue, yarn init
or yarn login
wouldn't work on git bash that gets installed with git for windows but they'd work on standard cmd
Most helpful comment
How is this going ?
Still working on this ? I'm facing this issue at the moment.