Describe the bug
In order to run cypress tests, I use the & operator to background the execution of the process as described here. This worked fine in Yarn 1, but in Yarn 2 if any script contains this operator I get
Syntax Error: Expected "$", "$(", "${", "&&", "'", ";", "<", "<<<", ">", ">>", "\"", "\\", "|", "|&", "||", [ \t], or end of input but "&" found (line 1, column 10).
at tt (/Users/wainwb01/repos/planv7/.yarn/releases/yarn-berry.js:28:320521)
at Object.parse (/Users/wainwb01/repos/planv7/.yarn/releases/yarn-berry.js:28:330627)
at Object.t.parseShell (/Users/wainwb01/repos/planv7/.yarn/releases/yarn-berry.js:28:315544)
at Object.t.execute (/Users/wainwb01/repos/planv7/.yarn/releases/yarn-berry.js:16:19878)
at A.configuration.reduceHook.script (/Users/wainwb01/repos/planv7/.yarn/releases/yarn-berry.js:16:5595)
at /Users/wainwb01/repos/planv7/.yarn/releases/yarn-berry.js:16:5724
at async s.mktempPromise (/Users/wainwb01/repos/planv7/.yarn/releases/yarn-berry.js:2:5648)
at async Object.B [as executePackageScript] (/Users/wainwb01/repos/planv7/.yarn/releases/yarn-berry.js:16:5355)
at async c.execute (/Users/wainwb01/repos/planv7/.yarn/releases/yarn-berry.js:50:58654)
at async c.validateAndExecute (/Users/wainwb01/repos/planv7/.yarn/releases/yarn-berry.js:16:50176)
To Reproduce
Add "&" to any "script" in your package.json then run the script
Same on my side on Windows: Following script is failing:
eslint --cache --fix ./ >/dev/null 2>&1 || true
Error:
Syntax Error: Expected "$", "$(", "${", "'", "\"", "\", or [ \t] but "&" found (line 1, column 38).
I'm experiencing the same issue, my environment:
node --version && yarn --version
v12.16.3
2.1.1
So will be the entire Drupal community if they try to run their "build" or "watch" script from this package.json with Yarn 2.
I hope this get a fix soon. Thank you so much for all the hard work.
Note that until we implement support for the & operator in our portable shell (which guarantees that things behave the same way on all platforms - e.g. environment variables - YARN_CHECKSUM_BEHAVIOR=ignore yarn install), you can run the script with another shell as an escape hatch:
{
"scripts": {
"build": "bash -c 'yarn build:css & yarn build:js'"
}
}
Most helpful comment
Note that until we implement support for the
&operator in our portable shell (which guarantees that things behave the same way on all platforms - e.g. environment variables -YARN_CHECKSUM_BEHAVIOR=ignore yarn install), you can run the script with another shell as an escape hatch: