find_program fails when looking for programs installed from Microsoft Store, such as pwsh
Hi,
There appears to be an issue affecting users on Windows when find_program is used to find something installed from the MS Store, for example PowerShell used by vcpkg: https://github.com/microsoft/vcpkg/issues/15681#issuecomment-939781072
Store apps create "App Execution Aliases" in %LOCALAPPDATA%\Microsoft\WindowsApps
, which is added to %PATH%
.
As far as I understand, SystemTools::FileExists() (and maybe FileIsExecutable() as well as any other similar function) would need to follow the alias links instead of attempting to CreateFile() on the alias itself, which fails and causes false negative find_program result.
The app execution alias has the FILE_ATTRIBUTE_REPARSE_POINT attribute. Adding FILE_FLAG_OPEN_REPARSE_POINT to CreateFileW() in SystemTools::FileExists() will probably fix the issue. Without it, one just gets ERROR_CANT_ACCESS_FILE.