-
Notifications
You must be signed in to change notification settings - Fork 429
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
Fix resolution of executable names on Windows. #1257
Fix resolution of executable names on Windows. #1257
Conversation
Thanks for your contribution! Please make sure to follow our Commit Convention. |
Could you provide references to other stdlib implementations showing that this is the correct approach for such an API? |
Most unix-like tools that are using spawn are using the standard C library _spawnlp for their Windows version and the version provided in the Microsoft C runtime does a FindExecutable call. We are not using the std C library, instead we are using the lower level CreateProcess call which requires the file name be fully resolved already. I'm not sure why we are using CreateProcess instead of spawn, but probably for stdio redirection? Many unix-derrived tools also get this wrong and try and reverse engineer the algorithm in FindExecutable, for example, see cmake implementation of spawn which calls But I did a bit more testing and found some more improvements. If the given command is already a full path pointing to an existing file then FindExecutable can do some weird things reverting to "8.3 short file format" which we don't want and I also generalized the adding of double quotes to handle the case where the incoming command also contains spaces already. |
I'm way out of my depth here, but the |
My question about other stdlibs stands btw. If everyone else has to special-case |
Another common option with process spawn APIs is an opt-in |
@Kha, you are right, FindExecutable is doing too much, so I switched to using SearchPath instead. I also tested the "We must escape the arguments to preseving spacing" code a bit more and it seems to be correct. |
@Kha - I think we still need to merge this so that Lake on Windows behaves better (See leanprover-community/lean4-samples#3). |
@lovettchris Thanks for working on this issue. It seems there is one pending issue on this thread.
Could you please provide references? I think this is a valid concern. |
How about the llvm debugger which has a ProcessLauncherWindows that calls the Win32 CreateProcess using a |
@lovettchris Good to see that others use similar workarounds, but I hope you can appreciate the difference between doing so in a private API in some software with clear use cases versus in a public API in a language's standard library.
|
Fwiw, I adjusted the originally mentioned |
Thanks, meanwhile I'm trying to fix it with this: #1257 |
I am closing this PR. @Kha raised an important point, and @lovettchris found an alternative fix. |
This lakefile.lean fails to build on windows because the command 'npm' has to be resolved to
C:\Program Files\nodejs\npm.cmd
and there is a special Windows API that does that called SearchPath. I've tested that this fix works and lake build is able to successfully complete the npm command using a locally patched version of lean.exe.