yarn icon indicating copy to clipboard operation
yarn copied to clipboard

yarn CLI does not work correctly in Git Bash for Windows 10

Open DTHutton opened this issue 4 years ago • 13 comments

  • OS: Windows 10
  • yarn: v1.21.1
  • git: v2.24.1.windows.2
  • node: v12.13.1

Replication Steps

  1. Open new Git Bash window
  2. cd into repo with a pre-existing package.json
  3. run yarn install

What is the current behavior? Literally nothing happens. No errors or messages of any kind and it goes right back to the default $ line. Additionally, after attempting to run a yarn command of any kind, anything typed afterward doesn't show up. The only thing that works is ctrl + C, but all that does is go right back to the default $ line that I mentioned before with the same behaviors.

What is the expected behavior? yarn should install dependencies or run scripts based on package.json file

Additional Info

  • yarn.cmd install works in Bash
  • npx create-react-app my-app will run and install using yarn with no issues, but yarn start runs into the same issues as above
  • yarn commands, such as yarn --version, work in the default command prompt
  • PATH is C:\Program Files (x86)\Yarn\bin
  • Restarted windows after yarn install
  • Re-installed yarn and restarted windows after the re-install

DTHutton avatar Dec 31 '19 04:12 DTHutton

Probably related behaviour that I currently struggle with. When running yarn install (with all the relevant dependencies already installed) the screen just gets cleared, and then, when finished, returns to input ($), when done. If I scroll up, you can see the hidden yarn install v1.13.0 line that I would expect.

yarn_bash_issue_1

If some dependencies are not installed yet, installation output eventually starts appearing, so probably it's only the initial output that gets hidden, and is confusing.

yarn_bash_issue_2

dubbha avatar Jan 14 '20 11:01 dubbha

This is what mine does. It does the same thing in the terminal for VSCode. yarnGitBashBug The only thing that you can do after that is ctrl + c. Nothing else works until you close that instance out and open a new one.

DTHutton avatar Jan 18 '20 19:01 DTHutton

Anyone got the solution on this?

arnagre avatar Jul 07 '20 12:07 arnagre

Interestingly, I found that if I run winpty bash in the terminal window, I get the same effect (without yarn). So that seems to trigger it as well.

If anybody has any workarounds, I'm all ears. Do we even know which program is the issue?

mtiller avatar Jul 13 '20 21:07 mtiller

It must be something that few bash doesn't recognize the yarn commands as @DTHutton is facing the same issue on VSCode and @mtiller you and me with GIT Bash. Just to continue my work, I'm using the IntelliJ IDEs Terminal.

arnagre avatar Jul 14 '20 04:07 arnagre

Are we really the only four people in the world having this problem? I would have expected this issue to be lighting up the issue tracker. For what it is worth, this doesn't actually seem to be a yarn issue directly. But yarn seems to trigger these issues. I suspect something about it's tty support (colors? cursor movement?). I'm running the following on the machine that is giving me difficulties:

Git: version 2.27.0.window2.1 Yarn: 1.22.4 Windows: Windows 10 Pro - Version 1909

But the following nearly identical machine doesn't have the issue:

Git: version 2.27.0.window2.1 Yarn: 1.22.4 Windows: Windows 10 Pro - Version 1803

So it seems pretty clear that the issue is not with yarn or git or bash per se, but rather something that changed from Windows 1803 to 1909. HTH.

mtiller avatar Jul 19 '20 17:07 mtiller

One more thing I've found. If my console becomes non-responsive due to this random issue popping up with yarn, I can run a command shell (cmd) and then just exit and things seem to return to normal. But it is such a pain to do that intermittently. Furthermore, running yarn again may or may not trigger the thing. It is like a flip of a coin so you can potentially end up doing this multiple times. 😢

P.S. - I tried the new Windows Terminal. The issue still happens. So definitely not a UI issue, it is something fundamental to the shell itself.

mtiller avatar Aug 10 '20 11:08 mtiller

Hi @mtiller , I know that's frustrating when it happens while working, I have moved on to windows powershell and nicely customized it. That's what we can do. Also added an option to open the exact folder by right click on windows to work and save time to traverse using cd . for ref: https://www.howtogeek.com/165268/how-to-add-open-powershell-here-to-the-context-menu-in-windows/

arnagre avatar Aug 10 '20 12:08 arnagre

OK, on other thing I found as a terrible kludge. If you want to run a command with yarn, you can do so reliable if you then pipe it to tee, e.g., yarn install | tee /dev/null. I know that is so stupid. But that makes yarn completely reliable. It never messes up. Why? No idea. Seems like tee would put out all the same characters as yarn. But somehow it keeps my shell from losing the ability to output.

mtiller avatar Aug 11 '20 23:08 mtiller

Cool, thanks!

arnagre avatar Aug 12 '20 04:08 arnagre

We just bumped into this. cmd works but Git BASH and PowerShell do not recognize yarn.

jhult avatar Apr 29 '21 20:04 jhult

It looks like this might be a duplicate of #5349.

jhult avatar Apr 29 '21 21:04 jhult

[video]

Having a similar problem. Git bash doesn't seem to find yarn, but it works fine on cmd or powershell.

moonman369 avatar May 09 '22 17:05 moonman369