Can be seen happening in https://circleci.com/gh/angular/angular-cli/108581#tests/containers/1
Related issues and PRs:
The importance of the distinction between child_process.exec() and child_process.execFile() can vary based on platform. On Unix-type operating systems (Unix, Linux, macOS) child_process.execFile() can be more efficient because it does not spawn a shell by default. On Windows, however, .bat and .cmd files are not executable on their own without a terminal, and therefore cannot be launched using child_process.execFile(). When running on Windows, .bat and .cmd files can be invoked using child_process.spawn() with the shell option set, with child_process.exec(), or by spawning cmd.exe and passing the .bat or .cmd file as an argument (which is what the shell option and child_process.exec() do). In any case, if the script filename contains spaces it needs to be quoted.
In order not to require shell in Windows. We'd need to change the spawn command to the below when running on windows
const { status, stderr, stdout, error } = child_process_1.spawnSync('cmd.exe', ['/c', packageManager, ...installArgs, ...extraArgs], {
stdio: 'pipe',
encoding: 'utf8',
cwd,
});
That being said, I don't think we should do anything (ie: leave shell: true) as based on the docs, this is what shell option does.
When running on Windows, .bat and .cmd files can be invoked using child_process.spawn() with the shell option set, with child_process.exec(), or by spawning cmd.exe and passing the .bat or .cmd file as an argument (which is what the shell option and child_process.exec() do).
Note: in the same there is also another spawnSync which uses shell
SGTM, great work getting to the bottom of this!
npm is a batch file on windows?
Looks like it:
PS C:\Users\kamik> get-command npm
CommandType Name Version Source
----------- ---- ------- ------
Application npm.cmd 0.0.0.0 C:\Program Files\nodejs\npm.cmd
PS C:\Users\kamik> get-command yarn
CommandType Name Version Source
----------- ---- ------- ------
Application yarn.cmd 0.0.0.0 C:\Program Files (x86)\Yarn\bin\yarn.cmd
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._