Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

program not found for corepack on Windows #110

Open
rakuzen25 opened this issue Jan 3, 2025 · 2 comments
Open

program not found for corepack on Windows #110

rakuzen25 opened this issue Jan 3, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@rakuzen25
Copy link

Thanks for this handy package! I have a monorepo set up with pnpm (side note: perhaps in addition to testing lock files to resolve the package manager, the program can prioritise the packageManager field in package.json if it's defined?), but it's installed via corepack and not globally. Hence, when I run sherif --fix, it's giving me an error.

 Note: running install command using pnpm...


 ⨯ error Failed to install packages
   program not found

Is there any way to honour the corepack version in rust?

@QuiiBz QuiiBz added the bug Something isn't working label Jan 4, 2025
@QuiiBz
Copy link
Owner

QuiiBz commented Jan 4, 2025

Interesting bug, I'm not very familiar with Corepack nor how it works so will have to dig more into this. Do you know how Corepack exposes package manager commands without having them registered in PATH?

@rakuzen25 rakuzen25 changed the title program not found when package manager not in PATH program not found for corepack on Windows Jan 15, 2025
@rakuzen25
Copy link
Author

Apologies for the delay - I just got around to looking at it today and dug into some source code for corepack. I realised the culprit was not because of PATH, but because of how Rust handles commands on Windows.

From the documentation on Command:

Note on Windows: For executable files with the .exe extension, it can be omitted when specifying the program for this Command. However, if the file has a different extension, a filename including the extension needs to be provided, otherwise the file won’t be found.

This is potentially due to a CVE released earlier last year on undocumented behaviour of the underlying spawner.

On the other hand, corepack uses @zkochan/cmd-shim under the hood to create scripts in the PATH (.cmd, .ps1 and a Cygwin bash version) that essentially executes node <corepack_dir>\node_modules\corepack\dist\pnpm.js. None of these are, of course, an exe binary.

I am not the Rust expert here, but I've seen some people mention Command::new("cmd.exe").args(["/c", "script.bat"]) (see rust-lang/rust#123728 and rust-lang/rust#94743). Perhaps we can consider something like that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants