yarnpkg / yarn

The 1.x line is frozen - features and bugfixes now happen on https://github.com/yarnpkg/berry
https://classic.yarnpkg.com
Other
41.44k stars 2.73k forks source link

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

Open DTHutton opened 4 years ago

DTHutton commented 4 years ago

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

dubbha commented 4 years ago

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

DTHutton commented 4 years ago

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.

arnagre commented 4 years ago

Anyone got the solution on this?

mtiller commented 4 years ago

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?

arnagre commented 4 years ago

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.

mtiller commented 4 years ago

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 commented 4 years ago

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.

arnagre commented 4 years ago

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/

mtiller commented 4 years ago

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.

arnagre commented 4 years ago

Cool, thanks!

jhult commented 3 years ago

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

jhult commented 3 years ago

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

moonman369 commented 2 years ago

[video]

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

syengo254 commented 2 months ago

This is because of the Execution-policy of scripts. See: https://learn.microsoft.com/en-gb/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.4 Set-ExecutionPolicy Unrestricted

Not this makes your system unsecure.