Verify latest release
pnpm version
10.32.1
Which area(s) of pnpm are affected? (leave empty if unsure)
CLI
Link to the code that reproduces this issue or a replay of the bug
https://github.com/maxpatiiuk/pnpm-windows-false-not-found/
Reproduction steps
-
Clone this repository
git clone https://github.com/maxpatiiuk/pnpm-windows-false-not-found
cd pnpm-windows-false-not-found
-
Install dependencies: pnpm install
-
Reproduce the error:
Windows (wrong error message):
> pnpm --filter sub-package exec prettier --check test.js
Checking formatting...
[warn] test.js
[warn] Code style issues found in the above file. Run Prettier with --write to fix.
C:\Users\mak13180\site\pnpm-windows-false-not-found\sub-package:
ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL Command "prettier" not found
macOS/linux (correct error message):
> pnpm --filter sub-package exec prettier --check test.js
Checking formatting...
[warn] test.js
[warn] Code style issues found in the above file. Run Prettier with --write to fix.
/Users/mak13180/s/e/pnpm-windows-false-not-found/sub-package:
ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL Command failed with exit code 1: prettier --check test.js
Describe the Bug
If pnpm --filter not-current-folder-package exec exited with an error, PNPM falsely claims the command was not found
Expected Behavior
It should print ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL Command failed with exit code 1: prettier --check test.js instead, just like on mac/linux
Investigation
I think the bug occurs here:
|
function isErrorCommandNotFound (command: string, error: CommandError, prependPaths: string[]): boolean { |
|
// Mac/Linux |
|
if (process.platform === 'linux' || process.platform === 'darwin') { |
|
return error.originalMessage === `spawn ${command} ENOENT` |
|
} |
|
|
|
// Windows |
|
if (process.platform === 'win32') { |
|
const { value: path } = prependDirsToPath(prependPaths) |
|
return !which.sync(command, { |
|
nothrow: true, |
|
path, |
|
}) |
|
} |
|
|
|
return false |
|
} |
On macOS/linux it checks the command output to determine if command failed due to command being not found.
On Windows it uses which. Is it possible which is invoked from a wrong folder when pnpm was called with --filter?
Alternatively, consider looking for the is not recognized as an internal or external command substring instead. This is the expected output if the command is really not found:
> pnpm --filter sub-package exec prettier --check test.js
'prettier' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\mak13180\site\pnpm-windows-false-not-found\sub-package:
ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL Command "prettier" not found
Which Node.js version are you using?
24.11.1
Which operating systems have you used?
If your OS is a Linux based, which one it is? (Include the version if relevant)
No response
Verify latest release
pnpm version
10.32.1
Which area(s) of pnpm are affected? (leave empty if unsure)
CLI
Link to the code that reproduces this issue or a replay of the bug
https://github.com/maxpatiiuk/pnpm-windows-false-not-found/
Reproduction steps
Clone this repository
git clone https://github.com/maxpatiiuk/pnpm-windows-false-not-found cd pnpm-windows-false-not-foundInstall dependencies:
pnpm installReproduce the error:
Windows (wrong error message):
macOS/linux (correct error message):
Describe the Bug
If
pnpm --filter not-current-folder-package execexited with an error, PNPM falsely claims the command was not foundExpected Behavior
It should print
ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL Command failed with exit code 1: prettier --check test.jsinstead, just like on mac/linuxInvestigation
I think the bug occurs here:
pnpm/exec/commands/src/exec.ts
Lines 397 to 413 in 4a36b9a
On macOS/linux it checks the command output to determine if command failed due to command being not found.
On Windows it uses
which. Is it possiblewhichis invoked from a wrong folder when pnpm was called with--filter?Alternatively, consider looking for the
is not recognized as an internal or external commandsubstring instead. This is the expected output if the command is really not found:Which Node.js version are you using?
24.11.1
Which operating systems have you used?
If your OS is a Linux based, which one it is? (Include the version if relevant)
No response