[rush] Ctrl+C during rushx command results in annoying "Terminate batch job?" prompt on Windows
Summary
If you run a rushx command on Windows and Ctrl+C, you get that annoying "Terminate batch job?" prompt. This does not happen when running the underlying command directly, and does not happen with other package managers (e.g. yarn), so this seems like a Rush-specific issue.
Repro steps
Run a rushx command and then Ctrl+C.
Standard questions
Please answer these questions to help us investigate your issue more quickly:
| Question | Answer |
|---|---|
@microsoft/rush globally installed version? |
5.43.0 |
rushVersion from rush.json? |
5.43.0 |
useWorkspaces from rush.json? |
true |
| Operating system? | Windows 10 |
| Would you consider contributing a PR? | No |
Node.js version (node -v)? |
14.15.0 |
I've noticed this issue as well. The only batch job/Windows shell script that gets invoked when you run rushx is the one that's generated by the package manager during installation to set up the bin global scripts. This is generated for everything, so I'm not sure how/why Yarn would be different.
Actually I just noticed that I also get a Terminate batch job (Y/N)? when running yarn install. Do you not see that? Which shell are you using?
@iclanton I'm using the standard git for Windows bash shell.
Does it repro if you do npm run ___ instead of rushx ___?
If I run with npm run or yarn run or pnpm run, the prompt does not appear. It appears only when using rushx.
Same/ Simlar problem? Whenever I use rushx in Windows PowerShell to run a nextjs app with 'rushx dev' if I hit ctrl C I will go into an infinite loop of being asked 'Terminate batch job (Y/N)' that I can't get out of without killing the shell or the shell becomes so slow that typing takes seconds for each character to appear. Using 'npm run dev' is never a problem. I quit using rushx months ago because of this.
The only known way to prevent Terminate batch job (Y/N) today is to perform a series of tricky command prompt loopholes in the launching batch script (here's an example). This is all under the purview of the package manager used to install the command you're running -- for NPM, you need version 7.x to get the new suppression behavior, while I believe yarn enabled it earlier.
As far as I can tell, if you install npm 6.x on a blank Windows box, and then you use npm to install both yarn and @microsoft/rush globally, then all 3 package managers should have identical (i.e. unwanted) behavior when typing Ctrl+C if launched from a Command Prompt or Powershell prompt.
Anything you install globally, with a recent Yarn or with NPM 7.x, should have the desired behavior (no prompt) when typing Ctrl+C if launched from a Command Prompt or Powershell prompt.
This doesn't line up exactly with the all the reports in the issue above, but hopefully it presents an upgrade path that will eliminate the issue either way.
This problem seems caused by npm because of it is default to use cmd.exe to exec scripts.the temporary method to sovle this is to run npm config set script-shell powershell.exe