Skip to content

After upgrading yarn on Windows, bash scripts won't run without hitting Enter #3540

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

Closed
kaiyoma opened this issue May 31, 2017 · 18 comments
Closed

Comments

@kaiyoma
Copy link

kaiyoma commented May 31, 2017

I upgraded from 0.23.3 to 0.24.6 today on my Windows 10 laptop and I'm seeing a problem whenever I run a bash script through yarn. I have several tasks defined in my package.json that look like this:

    ...
    "lesshint": "bash scripts/lesshint.sh",
    "lint": "bash scripts/lint.sh",
    ...

Now when I execute yarn run lint, the system hangs at this point:

$ yarn run lint
yarn run v0.24.6
$ bash scripts/lint.sh

Normally this script finishes in a few moments, but I noticed after the upgrade today that it was stuck after a minute. I checked Task Manager and nothing was happening. In the shell, I hit Enter and suddenly Node.js came to life in Task Manager and the script finished within a few moments.

This problem isn't happening with all of my shell script tasks, but it's happening with the most important ones.

@kaiyoma
Copy link
Author

kaiyoma commented May 31, 2017

I went back and installed old versions of yarn, upgrading incrementally, until I hit the problem. Version 0.24.3 worked fine, but 0.24.4 has the issue. As mentioned in the original post, 0.24.6 has the issue too. I tried installing the release candidate (0.25.3) and it suffers from the same issue as well.

@kaiyoma
Copy link
Author

kaiyoma commented May 31, 2017

I think I spoke too quickly; 0.24.1 has this issue too. The problem seems to be a bit non-deterministic, so it can be tricky to tell if the installed yarn is affected. I can't test 0.24.0 (there's no MSI file). Version 0.23.4 seems to be the last good version; I've run all my bash scripts multiple times and everything works fine. If I upgrade from this to 0.24.1 and try running my tests, something will hang until I press Enter.

@genu
Copy link

genu commented Jun 7, 2017

I can confirm this as well on Windows.

@Ant59
Copy link

Ant59 commented Jun 14, 2017

Can also confirm this issue. Scripts do not execute after yarn run x until another input into the Git Bash prompt on Windows.

@johnste
Copy link

johnste commented Aug 28, 2017

I have the same issue, 0.24.6, running from powershell or cmd.

@kaiyoma
Copy link
Author

kaiyoma commented Sep 13, 2017

Still an issue in 1.0.2.

@BYK
Copy link
Member

BYK commented Sep 13, 2017

I tried this on Windows 10 via cmd and wasn't able to replicate. That said I'm using WSL instead of Git bash so may be this is a problem with Git Bash?

@kaiyoma
Copy link
Author

kaiyoma commented Sep 13, 2017

I'm not sure who's at fault, but I do know for sure that the problem was introduced in yarn after version 0.23.4. I've downgraded to that version and I can run my scripts again without any issues. For reference, I'm running git 2.13.0 on Windows 10.

@BYK
Copy link
Member

BYK commented Sep 13, 2017

The only patch I've found that has the potential to affect yarn run between 0.23.4 and 0.24.0 was 50c5bf0

Would you like to try reverting this, getting a build and see if that's the cause?

@kaiyoma
Copy link
Author

kaiyoma commented Sep 13, 2017

It's also possible that a commit between 0.24.0 and 0.24.1 is the culprit. I can't find an MSI for 0.24.0 so I haven't been able to test that version.

@BYK
Copy link
Member

BYK commented Sep 13, 2017

It's also possible that a commit between 0.24.0 and 0.24.1 is the culprit.

That one is not possible: v0.24.0...v0.24.1

I think something went wrong when publishing 0.24.0 so they just bumped the version. Anyways, you can clone the repo, do git checkout -b test v0.24.1, git revert 50c5bf0cde3b71d00d889ff09582b2734b1d5423 and then get yourself a build. That said my suspicion is the added "global bin folder" to PATH code there. May be you have a globally installed script named bash or something? Or may be Windows's new WSL bash eecutable is clashing with Git's and yarn uses that one?

@kaiyoma
Copy link
Author

kaiyoma commented Sep 13, 2017

I'm still seeing the issue even after reverting that commit.

@BYK
Copy link
Member

BYK commented Sep 13, 2017

That's quite weird because there's nothing else touching the script running code between 0.23.4 and 0.24.1: v0.23.4...v0.24.1

Are you absolutely sure this never happens on 0.23.1 and this is not a problem with your specific configuration or system? Are you able to reproduce this on a different system?

@kaiyoma
Copy link
Author

kaiyoma commented Sep 14, 2017

The only thing changing on my system is the yarn version and I can repro the results 100% reliably: 0.23.4 and earlier is fine, but anything after that has the issue. I don't think it's specific to me as others have reported the same issue in this thread. Unfortunately, I don't have access to another system right now.

@kaiyoma
Copy link
Author

kaiyoma commented Sep 28, 2017

@BYK I finally browsed the link you posted (the list of changes between versions) and there's absolutely a change that would affect this behavior: a45a677

Maybe that's a good place to start debugging?

@kaiyoma
Copy link
Author

kaiyoma commented Sep 28, 2017

FYI, there were some interesting comments today on another thread I'm watching that also involves yarn, Windows, and winpty: #2591 (comment)

Maybe that could be helpful for this discussion too?

@kaiyoma
Copy link
Author

kaiyoma commented Oct 5, 2017

OMG, the answer was right in front of my face the whole time. So dumb. :-/

The problem is indeed with the commit I posted above. Previous to that change, use_winpty would be set to true for MSYS*|MINGW* shells, which includes Git Bash for Windows. After the change, the environment variable $YARN_FORCE_WINPTY is checked instead, which is clearly false if you don't set it yourself.

I can verify that after adding export YARN_FORCE_WINPTY=1 to my .bashrc and upgrading to Yarn 1.1.0, everything works again! I can run all my shell scripts just like I used to. 🎉

Leaving this issue open so the maintainers can decide if they want to switch around the logic to use winpty by default instead of the opposite.

@BYK
Copy link
Member

BYK commented Oct 30, 2017

I think this is addressed by #4577 so closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants