Describe the bug
As suggested in https://github.com/yarnpkg/yarn/issues/8358#issuecomment-701277649, I'm posting this issue in the berry repository.
I encountered this after upgrading yarn from npm to 1.22.10:
When executing the preinstall step of the npm package on Linux (no other OS tested as of now), the following error is thrown:
��� YN0000: ��� yarn@npm:1.22.10 STDERR SyntaxError: Expected "$", "$(", "$((", "${", "'", "\"", "\\", or [ \t] but "&" found (line 1, column 40).
��� YN0000: ��� yarn@npm:1.22.10 STDERR at fe (/var/lib/jenkins/workspace/frontend/.yarn/releases/yarn-2.2.2.js:55:361665)
��� YN0000: ��� yarn@npm:1.22.10 STDERR at parse (/var/lib/jenkins/workspace/frontend/.yarn/releases/yarn-2.2.2.js:55:376698)
��� YN0000: ��� yarn@npm:1.22.10 STDERR at i (/var/lib/jenkins/workspace/frontend/.yarn/releases/yarn-2.2.2.js:2:456775)
��� YN0000: ��� yarn@npm:1.22.10 STDERR at T (/var/lib/jenkins/workspace/frontend/.yarn/releases/yarn-2.2.2.js:2:488855)
��� YN0000: ��� yarn@npm:1.22.10 STDERR at i.configuration.reduceHook.script (/var/lib/jenkins/workspace/frontend/.yarn/releases/yarn-2.2.2.js:2:367760)
��� YN0000: ��� yarn@npm:1.22.10 STDERR at /var/lib/jenkins/workspace/frontend/.yarn/releases/yarn-2.2.2.js:2:367882
��� YN0000: ��� yarn@npm:1.22.10 STDERR at async a.mktempPromise (/var/lib/jenkins/workspace/frontend/.yarn/releases/yarn-2.2.2.js:2:447806)
��� YN0000: ��� yarn@npm:1.22.10 STDERR at async Module.k (/var/lib/jenkins/workspace/frontend/.yarn/releases/yarn-2.2.2.js:2:367500)
��� YN0000: ��� yarn@npm:1.22.10 STDERR at async /var/lib/jenkins/workspace/frontend/.yarn/releases/yarn-2.2.2.js:2:324596
��� YN0009: ��� yarn@npm:1.22.10 couldn't be built successfully (exit code 1, logs can be found here: /tmp/xfs-fe2baaa4/build.log)
��� YN0009: ��� yarn@npm:1.22.10 couldn't be built successfully (exit code 1, logs can be found here: /tmp/xfs-fe2baaa4/build.log)
To Reproduce
Execute the preinstall step of the npm package on Linux.
the preinstall step of the yarn npm package fails
``js repro
const installPromise = packageJsonAndInstall({
dependencies: {
[yarn]:1.22.10`,
},
});
await expect(installPromise)
.resolves.toBeTruthy();
```
Environment if relevant (please complete the following information):
This issue reproduces on master:
Error: expect(received).resolves.toBeTruthy()
Received promise rejected instead of resolved
Rejected to value: [Error: Command failed: /usr/bin/node /github/workspace/scripts/actions/../run-yarn.js install
➤ YN0000: ┌ Resolution step
::group::Resolution step
::endgroup::
➤ YN0000: └ Completed in 0s 304ms
➤ YN0000: ┌ Fetch step
::group::Fetch step
➤ YN0013: │ No packages were cached - one package had to be fetched
::endgroup::
➤ YN0000: └ Completed in 1s 724ms
➤ YN0000: ┌ Link step
::group::Link step
➤ YN0007: │ yarn@npm:1.22.10 must be built because it never did before or the last one failed
➤ YN0000: │ yarn@npm:1.22.10 STDERR SyntaxError: Expected "$", "$(", "$((", "${", "'", "\"", "\\", or [ \t] but "&" found (line 1, column 40).
➤ YN0000: │ yarn@npm:1.22.10 STDERR at peg$buildStructuredError (/github/workspace/packages/yarnpkg-parsers/sources/grammars/shell.js:396:12)
➤ YN0000: │ yarn@npm:1.22.10 STDERR at peg$parse (/github/workspace/packages/yarnpkg-parsers/sources/grammars/shell.js:2901:11)
➤ YN0000: │ yarn@npm:1.22.10 STDERR at parseShell (/github/workspace/packages/yarnpkg-parsers/sources/shell.ts:5:12)
➤ YN0000: │ yarn@npm:1.22.10 STDERR at execute (/github/workspace/packages/yarnpkg-shell/sources/index.ts:796:15)
➤ YN0000: │ yarn@npm:1.22.10 STDERR at executor (/github/workspace/packages/yarnpkg-core/sources/scriptUtils.ts:297:20)
➤ YN0000: │ yarn@npm:1.22.10 STDERR at /github/workspace/packages/yarnpkg-core/sources/scriptUtils.ts:306:18
➤ YN0000: │ yarn@npm:1.22.10 STDERR at NodeFS.mktempPromise (/github/workspace/packages/yarnpkg-fslib/sources/index.ts:389:18)
➤ YN0000: │ yarn@npm:1.22.10 STDERR at Object.executePackageScript (/github/workspace/packages/yarnpkg-core/sources/scriptUtils.ts:289:10)
➤ YN0000: │ yarn@npm:1.22.10 STDERR at /github/workspace/packages/yarnpkg-core/sources/Project.ts:1381:34
➤ YN0009: │ yarn@npm:1.22.10 couldn't be built successfully (exit code 1, logs can be found here: /tmp/xfs-672b8b8a/build.log)
➤ YN0009: │ yarn@npm:1.22.10 couldn't be built successfully (exit code 1, logs can be found here: /tmp/xfs-672b8b8a/build.log)
::endgroup::
➤ YN0000: └ Completed in 0s 649ms
➤ YN0000: Failed with errors in 2s 688ms
]
at expect (/github/workspace/.yarn/cache/expect-npm-24.8.0-8c7640c562-0ac41999f0.zip/node_modules/expect/build/index.js:138:15)
at module.exports (evalmachine.<anonymous>:8:7)
at /github/workspace/.yarn/cache/@arcanis-sherlock-npm-1.0.38-d4f5e2dbf3-63f998598d.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:56:19
at executeInTempDirectory (/github/workspace/.yarn/cache/@arcanis-sherlock-npm-1.0.38-d4f5e2dbf3-63f998598d.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:17:22)
at Object.executeRepro (/github/workspace/.yarn/cache/@arcanis-sherlock-npm-1.0.38-d4f5e2dbf3-63f998598d.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:24:18)
at ExecCommand.execute (/github/workspace/.yarn/cache/@arcanis-sherlock-npm-1.0.38-d4f5e2dbf3-63f998598d.zip/node_modules/@arcanis/sherlock/lib/commands/exec.js:25:59)
at async ExecCommand.validateAndExecute (/github/workspace/.yarn/cache/clipanion-npm-2.0.0-rc.16-b9444aaf89-a57989414f.zip/node_modules/clipanion/lib/advanced/Command.js:161:26)
at async Cli.run (/github/workspace/.yarn/cache/clipanion-npm-2.0.0-rc.16-b9444aaf89-a57989414f.zip/node_modules/clipanion/lib/advanced/Cli.js:74:24)
at async Cli.runExit (/github/workspace/.yarn/cache/clipanion-npm-2.0.0-rc.16-b9444aaf89-a57989414f.zip/node_modules/clipanion/lib/advanced/Cli.js:83:28)
I don't know in this particular case, but for example that's why the Vue CLI test is currently failing
Just for my own curiosity, why are you installing yarn@1 using yarn@2?
Just by coincidence: We're installing yarn via npm (which is globally available on Jenkins), which added the [email protected] dependency to the project-global package.json. Afterwards, yarn would trigger an install, using yarn@2 because that is specified in our .yarnrc.yml, find the freshly added [email protected] dependency, and execute the preinstall step.
We're now preventing this behaviour by using npm install --no-save to install yarn initially.
How are you installing it with npm? It should be npm install yarn -g which should not touch the project
How are you installing it with npm? It should be
npm install yarn -gwhich should not touch the project
We're installing it workspace-locally to prevent polluting our jenkins node.
We couldn't reproduce your issue (all the assertions passed on master).
Closing as the test is now passing after we've fixed issues in the shell