Describe the bug
If I try to install tbb (.\vcpkg.exe install tbb --triplet x64-windows), vcpkg reports that a suitable version of powershell-core was not found (6.2.1), but a suitable version is installed (6.2.3).
Environment
To Reproduce
Steps to reproduce the behavior:
pwsh.exe is available on the PATH by launching it from cmd.exe:```
Microsoft Windows [Version 10.0.18363.535]
(c) 2019 Microsoft Corporation. All rights reserved.
C:\Users\Jesse>pwsh.exe
PowerShell 6.2.3
Copyright (c) Microsoft Corporation. All rights reserved.
https://aka.ms/pscore6-docs
Type 'help' to get help.
PS C:\Users\Jesse>
```
./vcpkg.exe install tbb --triplet x64-windowsVcpkg doesn't find Poweshell Core:
PS C:\****\vcpkg> .\vcpkg.exe install tbb --triplet x64-windows
The following packages will be built and installed:
tbb[core]:x64-windows
Starting package 1/1: tbb:x64-windows
Building package tbb[core]:x64-windows...
A suitable version of powershell-core was not found (required v6.2.1). Downloading portable powershell-core v6.2.1...
Downloading powershell-core...
Expected behavior
Vcpkg should use the pwsh.exe installed at C:\Program Files\PowerShell\6\pwsh.exe and available on the PATH instead of downloading its own version.
@jesseschalken cc: @JackBoosY
See #8975
The rational behind vcpkg downloading it's own version of powershell is it uses specific commands and/or command syntax that may/may not be found in an older/newer version.
@timautry answer is right.
@timautry @JackBoosY I suppose the message is ambiguous wrt what "suitable" means in this context. I just assumed it meant semver compatible, but "exactly this version" would also be a legitimate interpretation.
Maybe instead of "suitable version" it should say "exact version" or "correct version" to be more precise? "Suitable" to me implies that there are multiple versions that would be considered "suitable" rather than just one.
vcpkg does not determine the powershell version. The version of the basic tools we use comes from _VCPKG_PATH/scripts/vcpkgTools.xml_. You can view the corresponding version in this file.
It's slightly misleading that it outputs a message like
A suitable version of powershell-core was not found (required v6.2.1). Downloading portable powershell-core v6.2.1...
When it's not actually trying to locate an installed powershell-core.
At one point, the download of powershell-core from the github releases was taking so long, that it was easier to write this quick workaround to check for an installed one, rather than waiting for it to finish:
@jesseschalken my changes attempt to implement what you suggest - checking for an installed pwsh.exe first (though only on PATH), and checking that the version matches what's specified in the vcpkgTools.xml.
I thought it might help this issue move forward to show that the desired behavior is (or appears to be) easy enough to implement, while respecting the version constraints.
I'll leave my comment here as well, since this issue is still open:
A bit annoying that vcpkg can't use the system powershell, if its version is high enough. For example I've got 6.2.4-64, only for vcpkg to install its own local 6.2.1-32... It doesn't use a lot of space, but still.
@ras0219-msft Could you take a look?
Part of the problem with finding/using the preinstalled helper tools like powershell is that the path gets sanitized. Gotta use VCPKG_ENV_PASSTHROUGH to keep your host PATH. Some of the community triplets have examples of this
Related: #7587
I'm having a similar issue, I have installed vcpkg (quite some time ago) but now when I use the Visual Studio "open folder" with cmake, it somehow always want to go through vcpkg and I can't even build an empty project because it fails to find powershell.
1> CMake generation started for configuration: 'x64-Debug'.
1> Command line: "cmd.exe" /c ""C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe" -G "Ninja" -DCMAKE_INSTALL_PREFIX:PATH="E:\progs\test\out\install\x64-Debug" -DCMAKE_C_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.25.28610/bin/HostX64/x64/cl.exe" -DCMAKE_CXX_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.25.28610/bin/HostX64/x64/cl.exe" -DCMAKE_TOOLCHAIN_FILE="E:/progs/PC/vcpkg/scripts/buildsystems/vcpkg.cmake" -DCMAKE_BUILD_TYPE="Debug" -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "E:\progs\test" 2>&1"
1> Working directory: E:\progs\test\out\build\x64-Debug
1> [CMake] -- The C compiler identification is MSVC 19.25.28614.0
1> [CMake] -- The CXX compiler identification is MSVC 19.25.28614.0
1> [CMake] -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.25.28610/bin/HostX64/x64/cl.exe
1> [CMake] -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.25.28610/bin/HostX64/x64/cl.exe -- broken
1> [CMake] CMake Error at C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake:60 (message):
1> [CMake] The C compiler
1> [CMake]
1> [CMake] "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.25.28610/bin/HostX64/x64/cl.exe"
1> [CMake]
1> [CMake] is not able to compile a simple test program.
1> [CMake]
1> [CMake] It fails with the following output:
1> [CMake]
1> [CMake] Change Dir: E:/progs/test/out/build/x64-Debug/CMakeFiles/CMakeTmp
1> [CMake]
1> [CMake] Run Build Command(s):C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe cmTC_e8c71 && [1/2] Building C object CMakeFiles\cmTC_e8c71.dir\testCCompiler.c.obj
1> [CMake] [2/2] Linking C executable cmTC_e8c71.exe
1> [CMake] FAILED: cmTC_e8c71.exe
1> [CMake] cmd.exe /C "cd . && "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_e8c71.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100183~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100183~1.0\x64\mt.exe --manifests -- C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1425~1.286\bin\Hostx64\x64\link.exe /nologo CMakeFiles\cmTC_e8c71.dir\testCCompiler.c.obj /out:cmTC_e8c71.exe /implib:cmTC_e8c71.lib /pdb:cmTC_e8c71.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cmd.exe /C "cd /D E:\progs\test\out\build\x64-Debug\CMakeFiles\CMakeTmp && powershell -noprofile -executionpolicy Bypass -file E:/progs/PC/vcpkg/scripts/buildsystems/msbuild/applocal.ps1 -targetBinary E:/progs/test/out/build/x64-Debug/CMakeFiles/CMakeTmp/cmTC_e8c71.exe -installedDir E:/progs/PC/vcpkg/installed/x64-windows/debug/bin -OutVariable out""
1> [CMake] 'powershell' n'est pas reconnu en tant que commande interne
1> [CMake] ou externe, un programme ex茅cutable ou un fichier de commandes.
1> [CMake] ninja: build stopped: subcommand failed.
1> [CMake]
1> [CMake]
1> [CMake]
1> [CMake]
1> [CMake]
1> [CMake] CMake will not be able to correctly generate this project.
1> [CMake] Call Stack (most recent call first):
1> [CMake] CMakeLists.txt:2 (project)
1> [CMake] -- Configuring incomplete, errors occurred!
1> [CMake] See also "E:/progs/test/out/build/x64-Debug/CMakeFiles/CMakeOutput.log".
1> [CMake] See also "E:/progs/test/out/build/x64-Debug/CMakeFiles/CMakeError.log".
1> [CMake]
1> cmd.exe /c ""C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe" -G "Ninja" -DCMAKE_INSTALL_PREFIX:PATH="E:\progs\test\out\install\x64-Debug" -DCMAKE_C_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.25.28610/bin/HostX64/x64/cl.exe" -DCMAKE_CXX_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.25.28610/bin/HostX64/x64/cl.exe" -DCMAKE_TOOLCHAIN_FILE="E:/progs/PC/vcpkg/scripts/buildsystems/vcpkg.cmake" -DCMAKE_BUILD_TYPE="Debug" -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "E:\progs\test" 2>&1" returned with exit code: 1
It seems to assume that powershell is in PATH but it seems it's not the case on my machine ?
I am also having the same issue. How can I solve it? It is a bit confused. I already installed system Power Shell Core 7.0.3, but vcpkg does not integrate with system power shell. It just show like that time and again.
Detecting compiler hash for triplet x64-windows...
A suitable version of powershell-core was not found (required v7.0.3). Downloading portable powershell-core v7.0.3...
Downloading powershell-core...
https://github.com/PowerShell/PowerShell/releases/download/v7.0.3/PowerShell-7.0.3-win-x86.zip -> C:\srcvcpkg\downloads\PowerShell-7.
I am also having the same issue. How can I solve it? It is a bit confused. I already installed system Power Shell Core 7.0.3, but vcpkg does not integrate with system power shell. It just show like that time and again.
Detecting compiler hash for triplet x64-windows...
A suitable version of powershell-core was not found (required v7.0.3). Downloading portable powershell-core v7.0.3...
Downloading powershell-core...
https://github.com/PowerShell/PowerShell/releases/download/v7.0.3/PowerShell-7.0.3-win-x86.zip -> C:\srcvcpkg\downloads\PowerShell-7.
Read the thread. The "A suitable version of powershell-core was not found" message is misleading. Vcpkg always downloads its own powershell and this is not a bug.
Read the thread. The "A suitable version of powershell-core was not found" message is misleading. Vcpkg always downloads its own powershell and this is not a bug.
By now I think many of us have read the thread as well as cross-linked threads. Perhaps a different issue masqueraded under a similar error, as a newcomer to vcpkg, just bootstrapped vcpkg.exe and trying to us it for installation (e.g. vcpkg install ..., the error shows:
- Could not automatically acquire pwsh because there is no entry in C:\Users\owner\vcpkg\scripts\vcpkgTools.xml for os=windows.
- You may be able to install pwsh via your system package manager.
I opened C:\Users\owner\vcpkg\scripts\vcpkgTools.xml, powershell-core is there, as is os=windows.
vcpkgTools.xml content
<!-- ... -->
<tool name="powershell-core" os="windows">
<version>7.0.3</version>
<exeRelativePath>pwsh.exe</exeRelativePath>
<url>https://github.com/PowerShell/PowerShell/releases/download/v7.0.3/PowerShell-7.0.3-win-x86.zip</url>
<sha512>2e410fc5e429fc6ad478976eff3efcffe9d53a0620c7c31c2b8bfe1f0976cade74632fc202bf58959cec111f03b824ba42ad4d74c8a66d67ec21bbfe9b9c626d</sha512>
<archiveName>PowerShell-7.0.3-win-x86.zip</archiveName>
</tool>
This bug report ranks as #1 on Google. Yahoo doesn't produce usable results, nor does DuckDuckGo and the README seems to reflect the steps I've followed. What if it doesn't download? I'm sure at least the Google users landed here trying to find out why. 馃嵒
Note, as a temporary workaround, I downloaded the powershell version referenced in the XML, extracted it and added that location to my PATH and it's proceeding.
just open vcpkg/scripts/vcpkgTools.xml and go to end of file. you will see <tool name="powershell-core" os="windows"> so change it to <tool name="pwsh" os="windows"> and save file.
Does this issue exists after merged PR https://github.com/microsoft/vcpkg/pull/13805?
Does this issue exists after merged PR #13805?
I did a git pull and a bootsrap-vcpkg and the issue reported here still exists. Happy to split it into a separate issue if needed.
cc @BillyONeal
@tresf Sorry about that, my fault. I didn't have great ideas for how to test that when a powershell core wasn't installed first, so I didn't write one, and of course it broke :(.
This bug report ranks as #1 on Google.
Right, that's why I wrote https://github.com/microsoft/vcpkg/pull/13805 which is what broke this 3 hours ago :/
Most helpful comment
just open vcpkg/scripts/vcpkgTools.xml and go to end of file. you will see
<tool name="powershell-core" os="windows">so change it to<tool name="pwsh" os="windows">and save file.