Yarn: Yarn causes batch files to bail early

Created on 28 Feb 2017  路  10Comments  路  Source: yarnpkg/yarn

Do you want to request a feature or report a bug?
bug

What is the current behavior?
When a batch script on Windows contains a call to yarn install, the exit of yarn install causes the entire batch file to exit with yarn's exit code

If the current behavior is a bug, please provide the steps to reproduce.
Given:

  • a folder with package.json/yarn.lock
  • a script with something like:
yarn install
echo "Test!"
  1. Run the batch file (.\test.bat)
  2. Watch as yarn install is run
  3. Watch as the script exits without running the echo line

What is the expected behavior?
The script should continue on after yarn install and run the commands following it

Please mention your node.js, yarn and operating system version.
node: 7.5.0
yarn: 0.20.3
os: Windows 10 (15031), Windows Server 2016, Windows Server 2012 R2

cat-bug os-windows triaged

Most helpful comment

This thread https://github.com/npm/npm/issues/2938 lead me to try "call yarn" and that makes it work that way you'd expect.

All 10 comments

An interesting note is that this doesn't affect PowerShell. If the repro script is written as a PowerShell script (test.ps1 rather than test.bat) and called via PowerShell, it works as expected.

Any new info about this or quick fixes?

when running yarn command with start in batch file it'll create a new command window instance and will not quit from main command window. the disadvantage is it breaks the command pipeline

...
start yarn
start npm start
...

Sorry for the lack of updates -- in the middle of moving and starting a new job so my time has been rather sparse. I'm trying to come up with a minimal reproduction case using the example code and aligning it more to the Typescript 2.4 stack I'm using.

Has there been any update on this? @berwyn have you figured out a workaround?

Did anyone try one of the latest nightlies? We've made a bunch of changes around how yarn exits so may be this is already resolved?

I've just tried on W7 with yarn install v1.1.0-20171003.1022. It still quits the batch file

This thread https://github.com/npm/npm/issues/2938 lead me to try "call yarn" and that makes it work that way you'd expect.

Just bumped into this issue today. Using "call yarn install" as suggested above does work.

Using "call yarn install" as suggested above does work

This works for yarn install and yarn build but I can't get it working in combination with set CI=true for yarn test. I've tried call set CI=true&&yarn test and various other combinations, which either don't abort when tests fail, or exit whether they pass or fail.

Was this page helpful?
0 / 5 - 0 ratings