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

'CMake' failed while extracting #33904

Open
HappySeaFox opened this issue Sep 20, 2023 · 41 comments · Fixed by microsoft/vcpkg-tool#1234
Open

'CMake' failed while extracting #33904

HappySeaFox opened this issue Sep 20, 2023 · 41 comments · Fixed by microsoft/vcpkg-tool#1234
Assignees
Labels
category:vcpkg-bug The issue is with the vcpkg system (including helper scripts in `scripts/cmake/`)

Comments

@HappySeaFox
Copy link
Contributor

HappySeaFox commented Sep 20, 2023

Describe the bug
I've just cloned and bootstrapped vcpkg. Cannot install any package because CMake cannot be unpacked. The antivirus software is disabled.

Environment

  • OS: Windows 7 x64
  • Compiler: MSVS 2019
  • PowerShell 5.1

To Reproduce

F:\projects\git.vcpkg>vcpkg install libjxl --triplet x64-windows
Computing installation plan...
A suitable version of cmake was not found (required v3.27.1) Downloading portable cmake 3.27.1...
Extracting cmake...
'CMake' failed while extracting F:\projects\git.vcpkg\downloads\cmake-3.27.1-windows-i386.zip.

P.S. Is there a way to get more logs?

@nobu
Copy link

nobu commented Sep 21, 2023

It seems failing on appveyor.com too.
https://ci.appveyor.com/project/ruby/ruby/builds/48067556#L47

Now we're downgrading to 2023-08-09 as a workaround.

@JonLiu1993
Copy link
Member

@HappySeaFox, Could you please add extra option --debug to the install command, retry then provide the output?

@JonLiu1993 JonLiu1993 added the category:question This issue is a question label Sep 21, 2023
@HappySeaFox
Copy link
Contributor Author

--debug log:

[DEBUG] To include the environment variables in debug output, pass --debug-env
[DEBUG] Trying to load bundleconfig from F:\projects\git.vcpkg\vcpkg-bundle.json
[DEBUG] Failed to open: F:\projects\git.vcpkg\vcpkg-bundle.json
[DEBUG] Bundle config: readonly=false, usegitregistry=false, embeddedsha=nullopt, deployment=Git, vsversion=nullopt
[DEBUG] Metrics enabled.
[DEBUG] Feature flag 'binarycaching' unset
[DEBUG] Feature flag 'compilertracking' unset
[DEBUG] Feature flag 'registries' unset
[DEBUG] Feature flag 'versions' unset
[DEBUG] Feature flag 'dependencygraph' unset
[DEBUG] Using scripts-root: F:\projects\git.vcpkg\scripts
[DEBUG] Using builtin-ports: F:\projects\git.vcpkg\ports
[DEBUG] Using installed-root: F:\projects\git.vcpkg\installed
[DEBUG] Using buildtrees-root: F:\projects\git.vcpkg\buildtrees
[DEBUG] Using packages-root: F:\projects\git.vcpkg\packages
[DEBUG] Using vcpkg-root: F:\projects\git.vcpkg
[DEBUG] Using scripts-root: F:\projects\git.vcpkg\scripts
[DEBUG] Using builtin-registry: F:\projects\git.vcpkg\versions
[DEBUG] Using downloads-root: F:\projects\git.vcpkg\downloads
[DEBUG] Could not use IsWow64Process2, trying IsWow64Process
Computing installation plan...
[DEBUG] Found path: C:\Program Files\CMake\bin\cmake.exe
[DEBUG] 1000: CreateProcessW("C:\Program Files\CMake\bin\cmake.exe" --version)
[DEBUG] 1000: cmd_execute_and_stream_data() returned 0 after    37334 us
[DEBUG] 1001: CreateProcessW("C:\Program Files\CMake\bin\cmake.exe" --version)
[DEBUG] 1001: cmd_execute_and_stream_data() returned 0 after    34905 us
A suitable version of cmake was not found (required v3.27.1) Downloading portable cmake 3.27.1...
[DEBUG] Trying to hash F:\projects\git.vcpkg\downloads\cmake-3.27.1-windows-i386.zip
[DEBUG] F:\projects\git.vcpkg\downloads\cmake-3.27.1-windows-i386.zip has hash a847f636fb27ba41ba9e6eaafa56937c614bcb39c6d0c9723241c229a9b0a77b4d00ebee88639561035d43f9aa64895f387eab56c628990c01191da57839cda0
Extracting cmake...
[DEBUG] Found path: C:\Program Files\CMake\bin\cmake.exe
[DEBUG] 1002: CreateProcessW("C:\Program Files\CMake\bin\cmake.exe" -E tar xzf "F:\projects\git.vcpkg\downloads\cmake-3.27.1-windows-i386.zip")
[DEBUG] 1002: cmd_execute() returned (error: calling CreateProcessW failed with 1450 (������������ ��������� �������� ��� ���������� ��������.)) after 1201 us
'CMake' failed while extracting F:\projects\git.vcpkg\downloads\cmake-3.27.1-windows-i386.zip.
[DEBUG] D:\a\_work\1\s\src\vcpkg\archives.cpp(323): 
[DEBUG] Time in subprocesses: 73440us
[DEBUG] Time in parsing JSON: 182us
[DEBUG] Time in JSON reader: 258us
[DEBUG] Time in filesystem: 1899us
[DEBUG] Time in loading ports: 1255us
[DEBUG] Exiting after 269 ms (263539us)

If I run "C:\Program Files\CMake\bin\cmake.exe" -E tar xzf "F:\projects\git.vcpkg\downloads\cmake-3.27.1-windows-i386.zip" in the same terminal window, it's able to unpack the archive.

@HappySeaFox
Copy link
Contributor Author

2023.08.09 version works fine, no errors were observed.

@JonLiu1993 JonLiu1993 added category:vcpkg-bug The issue is with the vcpkg system (including helper scripts in `scripts/cmake/`) and removed category:question This issue is a question labels Sep 22, 2023
@silverqx
Copy link
Contributor

I have the same problem on MSYS2 I tried both the master branch and also 2023.08.09 tag.

@silverqx
Copy link
Contributor

Here is the output, I have error 87 on MSYS2 and @HappySeaFox has 1450 error code.

vcpkg install "qtbase[core,sql-sqlite]" --debug
➜  vcpkg-tinyorm-port git:(9edb1b8e5) vcpkg install "qtbase[core,sql-sqlite]" --debug
[DEBUG] To include the environment variables in debug output, pass --debug-env
[DEBUG] Trying to load bundleconfig from C:\msys64\home\xyz\Code\vcpkg-tinyorm-port\vcpkg-bundle.json
[DEBUG] Failed to open: C:\msys64\home\xyz\Code\vcpkg-tinyorm-port\vcpkg-bundle.json
[DEBUG] Bundle config: readonly=false, usegitregistry=false, embeddedsha=nullopt, deployment=Git, vsversion=nullopt
[DEBUG] Metrics enabled.
[DEBUG] Feature flag 'binarycaching' unset
[DEBUG] Feature flag 'compilertracking' unset
[DEBUG] Feature flag 'registries' unset
[DEBUG] Feature flag 'versions' unset
[DEBUG] Feature flag 'dependencygraph' unset
[DEBUG] Using scripts-root: C:\msys64\home\xyz\Code\vcpkg-tinyorm-port\scripts
[DEBUG] Using builtin-ports: C:\msys64\home\xyz\Code\vcpkg-tinyorm-port\ports
[DEBUG] Using installed-root: C:\msys64\home\xyz\Code\vcpkg-tinyorm-port\installed
[DEBUG] Using buildtrees-root: C:\msys64\home\xyz\Code\vcpkg-tinyorm-port\buildtrees
[DEBUG] Using packages-root: C:\msys64\home\xyz\Code\vcpkg-tinyorm-port\packages
[DEBUG] Using vcpkg-root: C:\msys64\home\xyz\Code\vcpkg-tinyorm-port
[DEBUG] Using scripts-root: C:\msys64\home\xyz\Code\vcpkg-tinyorm-port\scripts
[DEBUG] Using builtin-registry: C:\msys64\home\xyz\Code\vcpkg-tinyorm-port\versions
[DEBUG] Using downloads-root: C:\msys64\home\xyz\Code\vcpkg-tinyorm-port\downloads
[DEBUG] Detecting host with IsWow64Process2
[DEBUG] Using overlay: C:/msys64/home/xyz/.local/share/vcpkg/ports
Computing installation plan...
[DEBUG] Loading dep info for: pcre2:x64-mingw-dynamic qtbase:x64-mingw-dynamic
[DEBUG] Found path: C:\msys64\ucrt64\bin\cmake.exe
[DEBUG] 1000: CreateProcessW("C:\msys64\ucrt64\bin\cmake.exe" --version)
[DEBUG] 1000: cmd_execute_and_stream_data() returned 0 after    21438 us
[DEBUG] 1001: CreateProcessW("C:\msys64\ucrt64\bin\cmake.exe" "-DVCPKG_ROOT_DIR=C:/msys64/home/xyz/Code/vcpkg-tinyorm-port" "-DPACKAGES_DIR=C:/msys64/home/xyz/Code/vcpkg-tinyorm-port/packages" "-DBUILDTREES_DIR=C:/msys64/home/xyz/Code/vcpkg-tinyorm-port/buildtrees" "-D_VCPKG_INSTALLED_DIR=C:/msys64/home/xyz/Code/vcpkg-tinyorm-port/installed" "-DDOWNLOADS=C:/msys64/home/xyz/Code/vcpkg-tinyorm-port/downloads" -DVCPKG_MANIFEST_INSTALL=OFF -P "C:\msys64\home\xyz\Code\vcpkg-tinyorm-port\buildtrees\0.vcpkg_dep_info.cmake")
[DEBUG] 1001: cmd_execute_and_stream_data() returned 0 after    21008 us
[DEBUG] 1002: CreateProcessW("C:\msys64\ucrt64\bin\cmake.exe" "-DVCPKG_ROOT_DIR=C:/msys64/home/xyz/Code/vcpkg-tinyorm-port" "-DPACKAGES_DIR=C:/msys64/home/xyz/Code/vcpkg-tinyorm-port/packages" "-DBUILDTREES_DIR=C:/msys64/home/xyz/Code/vcpkg-tinyorm-port/buildtrees" "-D_VCPKG_INSTALLED_DIR=C:/msys64/home/xyz/Code/vcpkg-tinyorm-port/installed" "-DDOWNLOADS=C:/msys64/home/xyz/Code/vcpkg-tinyorm-port/downloads" -DVCPKG_MANIFEST_INSTALL=OFF -P "C:\msys64\home\xyz\Code\vcpkg-tinyorm-port\buildtrees\0.vcpkg_tags.cmake")
[DEBUG] 1002: cmd_execute_and_stream_data() returned 0 after    22806 us
The following packages will be built and installed:
  * bzip2[core,tool]:x64-mingw-dynamic -> 1.0.8#5
  * double-conversion:x64-mingw-dynamic -> 3.2.1#1
  * pcre2[core,jit,platform-default-features]:x64-mingw-dynamic -> 10.42
    qtbase[concurrent,core,doubleconversion,sql,sql-sqlite,thread]:x64-mingw-dynamic -> 6.5.2#1
  * sqlite3[core,json1]:x64-mingw-dynamic -> 3.42.0#1
  * vcpkg-cmake:x64-mingw-dynamic -> 2023-05-04
  * vcpkg-cmake-config:x64-mingw-dynamic -> 2022-02-06#1
  * zlib:x64-mingw-dynamic -> 1.2.13
Additional packages (*) will be modified to complete this operation.
[DEBUG] Detecting host with IsWow64Process2
[DEBUG] Detecting host with IsWow64Process2
[DEBUG] Trying to hash C:\msys64\home\xyz\Code\vcpkg-tinyorm-port\scripts\toolchains/mingw.cmake
[DEBUG] C:\msys64\home\xyz\Code\vcpkg-tinyorm-port\scripts\toolchains/mingw.cmake has hash 5b8d970aac9ea752ee4bcbbdc87807ef4b73513c48a3c322508c3940dd6ab69c
[DEBUG] Trying to hash C:\msys64\home\xyz\Code\vcpkg-tinyorm-port\triplets\community\x64-mingw-dynamic.cmake
[DEBUG] C:\msys64\home\xyz\Code\vcpkg-tinyorm-port\triplets\community\x64-mingw-dynamic.cmake has hash 621e918dca7fdc6cb403bce0ba31dcf1fc68dfe47bec975bdcc66f0ea79dc548
Detecting compiler hash for triplet x64-mingw-dynamic...
[DEBUG] Found path: C:\msys64\usr\bin\git.exe
[DEBUG] 1003: CreateProcessW("C:\msys64\usr\bin\git.exe" --version)
[DEBUG] 1003: cmd_execute_and_stream_data() returned 0 after    21736 us
A suitable version of powershell-core was not found (required v7.2.11) Downloading portable powershell-core 7.2.11...
[DEBUG] Trying to hash C:\msys64\home\xyz\Code\vcpkg-tinyorm-port\downloads\PowerShell-7.2.11-win-x86.zip
[DEBUG] C:\msys64\home\xyz\Code\vcpkg-tinyorm-port\downloads\PowerShell-7.2.11-win-x86.zip has hash e9581122101ad161ad628a6feb63e61d3ef8f064a3f325465e8a1a4a6cfc1affbc9bf63146efae0aa65ff9ea5c93018af2c413dc0940f0d162edef805659ec84
Extracting powershell-core...
[DEBUG] 1004: CreateProcessW("C:\msys64\ucrt64\bin\cmake.exe" -E tar xzf "C:\msys64\home\xyz\Code\vcpkg-tinyorm-port\downloads\PowerShell-7.2.11-win-x86.zip")
[DEBUG] 1004: cmd_execute() returned (error: calling CreateProcessW failed with 87 (unknown error)) after 707 us
'CMake' failed while extracting C:\msys64\home\xyz\Code\vcpkg-tinyorm-port\downloads\PowerShell-7.2.11-win-x86.zip.
[DEBUG] D:\a\_work\1\s\src\vcpkg\archives.cpp(323):
[DEBUG] Time in subprocesses: 87695us
[DEBUG] Time in parsing JSON: 603us
[DEBUG] Time in JSON reader: 427us
[DEBUG] Time in filesystem: 12975us
[DEBUG] Time in loading ports: 2505us
[DEBUG] Exiting after 283 ms (272692us)

@HappySeaFox
Copy link
Contributor Author

@silverqx Try bootstrapping again after switching to 2023.08.09.

@silverqx
Copy link
Contributor

You are right I forgot bootstrap again, thx

@gg340th
Copy link

gg340th commented Sep 22, 2023

Same issue.
Switching to 2022.09.27 fixed it for me. (I haven't tried any other, so a more recent one probably works too)

nobu added a commit to nobu/ruby that referenced this issue Sep 22, 2023
microsoft/vcpkg#33904 (comment)

This reverts commit 8f1b688, "Revert
vcpkg.exe to previous release [ci skip]".
@BillyONeal
Copy link
Member

[DEBUG] 1002: CreateProcessW("C:\Program Files\CMake\bin\cmake.exe" -E tar xzf "F:\projects\git.vcpkg\downloads\cmake-3.27.1-windows-i386.zip")
[DEBUG] 1002: cmd_execute() returned (error: calling CreateProcessW failed with 1450 (������������ ��������� �������� ��� ���������� ��������.)) after 1201 us
'CMake' failed while extracting F:\projects\git.vcpkg\downloads\cmake-3.27.1-windows-i386.zip.

https://james.darpinian.com/decoder/?q=1450 says ERROR_NO_SYSTEM_RESOURCES . Is it possible that this machine is running out of memory or disk space?

It seems failing on appveyor.com too.
https://ci.appveyor.com/project/ruby/ruby/builds/48067556#L47

Is this also Windows 7?

Switching to 2022.09.27 fixed it for me. (I haven't tried any other, so a more recent one probably works too)

OK, so you're saying tool release 2023-09-15 does not exhibit the problem?

I have the same problem on MSYS2 I tried both the master branch and also 2023.08.09 tag.

OK, so this is saying 2023-09-15 does exhibit the problem?

Can someone with the problem try manually downloading vcpkg.exes and let us know when it works or stops working? https://github.com/microsoft/vcpkg-tool/releases

@JavierMatosD It seems like we should not be trying to use cmake to unpack cmake? I'd say might be related microsoft/vcpkg-tool#1039 but if it were that I'd expect we'd have gotten this reported earlier.

@HappySeaFox
Copy link
Contributor Author

HappySeaFox commented Oct 16, 2023

@BillyONeal

Is it possible that this machine is running out of memory or disk space?

Nope, it has a lot of free space and memory.

The 2023.08.09 version works fine. The issue was introduced after this tag.

@silverqx
Copy link
Contributor

silverqx commented Oct 16, 2023

I tried the master branch now on msys2 and still the same problem as I posted a few posts above. I'm on latest Win11 and latest msys2. Windows 7 😂 which normal developer would use Win7 😂

@silverqx
Copy link
Contributor

Can someone with the problem try manually downloading vcpkg.exes and let us know when it works or stops working? https://github.com/microsoft/vcpkg-tool/releases

I also tried this on msys2 and the same problem.

@autoantwort
Copy link
Contributor

I am getting error 87. interestingly not when I run vcpkg-tool from inside of QtCreator but when I try to run vcpkg-tool outside of QtCreator it fails with error 87. (I build vcpkg-tool inside of QtCreator)

@autoantwort
Copy link
Contributor

Ok the root cause seems to be that i was in a bash shell. Running the command inside of powershell works. But using powershell started from bash also does not work.

@Neumann-A
Copy link
Contributor

I see the same behavior as autoantwort with vcpkg env. Running in git bash doesn't work running normally in cmd works.

@BillyONeal
Copy link
Member

Can someone with the problem try manually downloading vcpkg.exes and let us know when it works or stops working? https://github.com/microsoft/vcpkg-tool/releases

I also tried this on msys2 and the same problem.

Can you explain what 'tried on msys2' means? (There's no vcpkg fetch msys2)

@BillyONeal
Copy link
Member

Windows 7 😂 which normal developer would use Win7 😂

The original report with the funny ERROR_NO_SYSTEM_RESOURCES code was Win7.

@BillyONeal
Copy link
Member

It seems failing on appveyor.com too. https://ci.appveyor.com/project/ruby/ruby/builds/48067556#L47

@nobu is this being run with bash?

@greenozon
Copy link

greenozon commented Oct 17, 2023

Looks like I"m hitting similar issue as described in this thread
WIn7 x64 SP1
running inside OS cmd.exe window:

vcpkg.exe install polyhook2 --triplet x64-windows --debug

ended up in a very strange error, but similar to above posts:

....
Extracting powershell-core...
[DEBUG] 1005: CreateProcessW("C:\from_gh\vcpkg\downloads\tools\cmake-3.27.1-windows\cmake-3.27.1-windows-i386/bin/cmake.exe" -E tar xzf "C:\from_gh\vcpkg\downloads\PowerShell-7.2.11-win-x86.zip")
[DEBUG] 1005: cmd_execute() returned (error: calling CreateProcessW failed with 1450 (unknown error)) after 5489 us
'CMake' failed while extracting C:\from_gh\vcpkg\downloads\PowerShell-7.2.11-win-x86.zip.
[DEBUG] D:\a\_work\1\s\src\vcpkg\archives.cpp(323):
[DEBUG] Time in subprocesses: 155878us
[DEBUG] Time in parsing JSON: 483us
[DEBUG] Time in JSON reader: 524us
[DEBUG] Time in filesystem: 6121us
[DEBUG] Time in loading ports: 2308us
[DEBUG] Exiting after 704 ms (703116us)

@BillyONeal BillyONeal reopened this Oct 18, 2023
@BillyONeal BillyONeal added the requires:tool-release An issue that has been fixed in the microsoft/vcpkg-tool repo and is waiting for a release thereof label Oct 18, 2023
@silverqx
Copy link
Contributor

silverqx commented Oct 18, 2023

How can I test it? Or when a new release will be out?

@BillyONeal
Copy link
Member

Should be fixed by #34548

@BillyONeal BillyONeal removed the requires:tool-release An issue that has been fixed in the microsoft/vcpkg-tool repo and is waiting for a release thereof label Oct 19, 2023
@silverqx
Copy link
Contributor

It's fixed and works fine, tested in MSYS2 shell with vcpkg install "qtbase[core,sql-sqlite]", thx for the fix @BillyONeal

@BillyONeal
Copy link
Member

No problem, thanks for confirming!

@BillyONeal
Copy link
Member

@HappySeaFox Is the Windows 7 problem you experienced fixed? I'm hopeful that the different error message you got is from the different OS but we have yet to reproduce that exact outcome...

@HappySeaFox
Copy link
Contributor Author

HappySeaFox commented Oct 25, 2023

Sorry for the late response. I've just cloned a fresh copy of vcpkg. The problem is still there:

>git rev-parse HEAD
7a6f366cefd27210f6a8309aed10c31104436509

>bootstrap-vcpkg.bat
Downloading https://github.com/microsoft/vcpkg-tool/releases/download/2023-10-18/vcpkg.exe -> F:\projects
\git.vcpkg\vcpkg.exe... done.
Validating signature... done.

vcpkg package management program version 2023-10-18-27de5b69dac4b6fe8259d283cd4011e6d20a84ce

See LICENSE.txt for license information.
Telemetry
---------
vcpkg collects usage data in order to help us improve your experience.
The data collected by Microsoft is anonymous.
You can opt-out of telemetry by re-running the bootstrap-vcpkg script with -disableMetrics,
passing --disable-metrics to vcpkg on the command line,
or by setting the VCPKG_DISABLE_METRICS environment variable.

Read more about vcpkg telemetry at docs/about/privacy.md

>vcpkg install libjpeg-turbo --triplet x64-windows --debug > log.txt 2>&1

The log:

[DEBUG] To include the environment variables in debug output, pass --debug-env
[DEBUG] Trying to load bundleconfig from F:\projects\git.vcpkg\vcpkg-bundle.json
[DEBUG] Failed to open: F:\projects\git.vcpkg\vcpkg-bundle.json
[DEBUG] Bundle config: readonly=false, usegitregistry=false, embeddedsha=nullopt, deployment=Git, vsversion=nullopt
[DEBUG] Metrics enabled.
[DEBUG] Feature flag 'binarycaching' unset
[DEBUG] Feature flag 'compilertracking' unset
[DEBUG] Feature flag 'registries' unset
[DEBUG] Feature flag 'versions' unset
[DEBUG] Feature flag 'dependencygraph' unset
[DEBUG] Using scripts-root: F:\projects\git.vcpkg\scripts
[DEBUG] Using builtin-ports: F:\projects\git.vcpkg\ports
[DEBUG] Using installed-root: F:\projects\git.vcpkg\installed
[DEBUG] Using buildtrees-root: F:\projects\git.vcpkg\buildtrees
[DEBUG] Using packages-root: F:\projects\git.vcpkg\packages
[DEBUG] Using vcpkg-root: F:\projects\git.vcpkg
[DEBUG] Using scripts-root: F:\projects\git.vcpkg\scripts
[DEBUG] Using builtin-registry: F:\projects\git.vcpkg\versions
[DEBUG] Using downloads-root: F:\projects\git.vcpkg\downloads
[DEBUG] Could not use IsWow64Process2, trying IsWow64Process
Computing installation plan...
[DEBUG] Found path: C:\Program Files\CMake\bin\cmake.exe
[DEBUG] 1000: CreateProcessW("C:\Program Files\CMake\bin\cmake.exe" --version)
[DEBUG] 1000: cmd_execute_and_stream_data() returned 0 after    50429 us
[DEBUG] 1001: CreateProcessW("C:\Program Files\CMake\bin\cmake.exe" -DVCPKG_ROOT_DIR=F:/projects/git.vcpkg -DPACKAGES_DIR=F:/projects/git.vcpkg/packages -DBUILDTREES_DIR=F:/projects/git.vcpkg/buildtrees -D_VCPKG_INSTALLED_DIR=F:/projects/git.vcpkg/installed -DDOWNLOADS=F:/projects/git.vcpkg/downloads -DVCPKG_MANIFEST_INSTALL=OFF -P "F:\projects\git.vcpkg\buildtrees\0.vcpkg_tags.cmake")
[DEBUG] 1001: cmd_execute_and_stream_data() returned 0 after    30994 us
The following packages will be built and installed:
    libjpeg-turbo:x64-windows -> 3.0.1
  * vcpkg-cmake:x64-windows -> 2023-05-04
  * vcpkg-cmake-config:x64-windows -> 2022-02-06#1
Additional packages (*) will be modified to complete this operation.
[DEBUG] 1002: CreateProcessW("C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -all -prerelease -legacy -products * -format xml)
[DEBUG] 1002: cmd_execute_and_stream_data() returned 0 after    30876 us
[DEBUG] Trying to hash F:\projects\git.vcpkg\scripts\toolchains/windows.cmake
[DEBUG] F:\projects\git.vcpkg\scripts\toolchains/windows.cmake has hash e36df1c7f50ab25f9c182fa927d06c19ae082e0d599f132b3f655784b49e4b33
[DEBUG] Trying to hash F:\projects\git.vcpkg\triplets\x64-windows.cmake
[DEBUG] F:\projects\git.vcpkg\triplets\x64-windows.cmake has hash 4556164a2cd3dd6f4742101eabb46def7e71b6e5856faa88e5d005aac12a803c
Detecting compiler hash for triplet x64-windows...
[DEBUG] Found path: C:\dev\Git\cmd\git.exe
[DEBUG] 1003: CreateProcessW("C:\dev\Git\cmd\git.exe" --version)
[DEBUG] 1003: cmd_execute_and_stream_data() returned 0 after    38903 us
[DEBUG] Could not use IsWow64Process2, trying IsWow64Process
A suitable version of powershell-core was not found (required v7.2.11) Downloading portable powershell-core 7.2.11...
[DEBUG] Trying to hash F:\projects\git.vcpkg\downloads\PowerShell-7.2.11-win-x86.zip
[DEBUG] F:\projects\git.vcpkg\downloads\PowerShell-7.2.11-win-x86.zip has hash e9581122101ad161ad628a6feb63e61d3ef8f064a3f325465e8a1a4a6cfc1affbc9bf63146efae0aa65ff9ea5c93018af2c413dc0940f0d162edef805659ec84
Extracting powershell-core...
[DEBUG] 1004: CreateProcessW("C:\Program Files\CMake\bin\cmake.exe" -E tar xzf "F:\projects\git.vcpkg\downloads\PowerShell-7.2.11-win-x86.zip")
[DEBUG] 1004: cmd_execute() returned (error: calling CreateProcessW failed with 1450 (������������ ��������� �������� ��� ���������� ��������.)) after 1697 us
'CMake' failed while extracting F:\projects\git.vcpkg\downloads\PowerShell-7.2.11-win-x86.zip.
[DEBUG] D:\a\_work\1\s\src\vcpkg\archives.cpp(323): 
[DEBUG] Time in subprocesses: 152899us
[DEBUG] Time in parsing JSON: 95us
[DEBUG] Time in JSON reader: 158us
[DEBUG] Time in filesystem: 1743us
[DEBUG] Time in loading ports: 978us
[DEBUG] Exiting after 620 ms (609380us)

Tested with two shells: the system cmd and the built-in shell in FAR Manager.

nobu added a commit to nobu/ruby that referenced this issue Oct 25, 2023
microsoft/vcpkg#33904

This reverts commit 8f1b688, "Revert
vcpkg.exe to previous release [ci skip]".
@JonLiu1993 JonLiu1993 reopened this Oct 25, 2023
@HappySeaFox
Copy link
Contributor Author

HappySeaFox commented Oct 28, 2023

More interesting results:

vcpkg install libjpeg-turbo --triplet x64-windows in FAR Manager: 'CMake' failed while extracting

vcpkg install libjpeg-turbo --triplet x64-windows in cmd: Failed to write to stdout: 31

Log F:\projects\git.vcpkg>vcpkg install libjpeg-turbo --triplet x64-windows --debug [DEBUG] To include the environment variables in debug output, pass --debug-env [DEBUG] Trying to load bundleconfig from F:\projects\git.vcpkg\vcpkg-bundle.json

[DEBUG] Failed to open: F:\projects\git.vcpkg\vcpkg-bundle.json
[DEBUG] Bundle config: readonly=false, usegitregistry=false, embeddedsha=nullopt
, deployment=Git, vsversion=nullopt
[DEBUG] Metrics enabled.
[DEBUG] Feature flag 'binarycaching' unset
[DEBUG] Feature flag 'compilertracking' unset
[DEBUG] Feature flag 'registries' unset
[DEBUG] Feature flag 'versions' unset
[DEBUG] Feature flag 'dependencygraph' unset
[DEBUG] Using scripts-root: F:\projects\git.vcpkg\scripts
[DEBUG] Using builtin-ports: F:\projects\git.vcpkg\ports
[DEBUG] Using installed-root: F:\projects\git.vcpkg\installed
[DEBUG] Using buildtrees-root: F:\projects\git.vcpkg\buildtrees
[DEBUG] Using packages-root: F:\projects\git.vcpkg\packages
[DEBUG] Using vcpkg-root: F:\projects\git.vcpkg
[DEBUG] Using scripts-root: F:\projects\git.vcpkg\scripts
[DEBUG] Using builtin-registry: F:\projects\git.vcpkg\versions
[DEBUG] Using downloads-root: F:\projects\git.vcpkg\downloads
[DEBUG] Could not use IsWow64Process2, trying IsWow64Process
Computing installation plan...
[DEBUG] Found path: C:\Program Files\CMake\bin\cmake.exe
[DEBUG] 1000: CreateProcessW("C:\Program Files\CMake\bin\cmake.exe" --version)
[DEBUG] 1000: cmd_execute_and_stream_data() returned 0 after 45663 us
[DEBUG] 1001: CreateProcessW("C:\Program Files\CMake\bin\cmake.exe" -DVCPKG_ROOT
_DIR=F:/projects/git.vcpkg -DPACKAGES_DIR=F:/projects/git.vcpkg/packages -DBUILD
TREES_DIR=F:/projects/git.vcpkg/buildtrees -D_VCPKG_INSTALLED_DIR=F:/projects/gi
t.vcpkg/installed -DDOWNLOADS=F:/projects/git.vcpkg/downloads -DVCPKG_MANIFEST_I
NSTALL=OFF -P "F:\projects\git.vcpkg\buildtrees\0.vcpkg_tags.cmake")
[DEBUG] 1001: cmd_execute_and_stream_data() returned 0 after 32426 us
The following packages will be built and installed:
libjpeg-turbo:x64-windows -> 3.0.1

  • vcpkg-cmake:x64-windows -> 2023-05-04
  • vcpkg-cmake-config:x64-windows -> 2022-02-06#1
    Additional packages (*) will be modified to complete this operation.
    [DEBUG] 1002: CreateProcessW("C:\Program Files (x86)\Microsoft Visual Studio\Ins
    taller\vswhere.exe" -all -prerelease -legacy -products * -format xml)
    [DEBUG] 1002: cmd_execute_and_stream_data() returned 0 after 30425 us
    [DEBUG] Trying to hash F:\projects\git.vcpkg\scripts\toolchains/windows.cmake
    [DEBUG] F:\projects\git.vcpkg\scripts\toolchains/windows.cmake has hash e36df1c7
    f50ab25f9c182fa927d06c19ae082e0d599f132b3f655784b49e4b33
    [DEBUG] Trying to hash F:\projects\git.vcpkg\triplets\x64-windows.cmake
    [DEBUG] F:\projects\git.vcpkg\triplets\x64-windows.cmake has hash 4556164a2cd3dd
    6f4742101eabb46def7e71b6e5856faa88e5d005aac12a803c
    Detecting compiler hash for triplet x64-windows...
    [DEBUG] Found path: C:\dev\Git\cmd\git.exe
    [DEBUG] 1003: CreateProcessW("C:\dev\Git\cmd\git.exe" --version)
    [DEBUG] 1003: cmd_execute_and_stream_data() returned 0 after 41103 us
    [DEBUG] Could not use IsWow64Process2, trying IsWow64Process
    A suitable version of powershell-core was not found (required v7.2.11) Downloadi
    ng portable powershell-core 7.2.11...
    [DEBUG] Trying to hash F:\projects\git.vcpkg\downloads\PowerShell-7.2.11-win-x86
    .zip
    [DEBUG] F:\projects\git.vcpkg\downloads\PowerShell-7.2.11-win-x86.zip has hash e
    9581122101ad161ad628a6feb63e61d3ef8f064a3f325465e8a1a4a6cfc1affbc9bf63146efae0aa
    65ff9ea5c93018af2c413dc0940f0d162edef805659ec84
    Extracting powershell-core...
    [DEBUG] 1004: CreateProcessW("C:\Program Files\CMake\bin\cmake.exe" -E tar xzf "
    F:\projects\git.vcpkg\downloads\PowerShell-7.2.11-win-x86.zip")
    [DEBUG] Failed to write to stdout: 31

vcpkg install libjpeg-turbo --triplet x64-windows > log.txt 2>&1 in cmd: 'CMake' failed while extracting

Log [DEBUG] To include the environment variables in debug output, pass --debug-env [DEBUG] Trying to load bundleconfig from F:\projects\git.vcpkg\vcpkg-bundle.json [DEBUG] Failed to open: F:\projects\git.vcpkg\vcpkg-bundle.json [DEBUG] Bundle config: readonly=false, usegitregistry=false, embeddedsha=nullopt, deployment=Git, vsversion=nullopt [DEBUG] Metrics enabled. [DEBUG] Feature flag 'binarycaching' unset [DEBUG] Feature flag 'compilertracking' unset [DEBUG] Feature flag 'registries' unset [DEBUG] Feature flag 'versions' unset [DEBUG] Feature flag 'dependencygraph' unset [DEBUG] Using scripts-root: F:\projects\git.vcpkg\scripts [DEBUG] Using builtin-ports: F:\projects\git.vcpkg\ports [DEBUG] Using installed-root: F:\projects\git.vcpkg\installed [DEBUG] Using buildtrees-root: F:\projects\git.vcpkg\buildtrees [DEBUG] Using packages-root: F:\projects\git.vcpkg\packages [DEBUG] Using vcpkg-root: F:\projects\git.vcpkg [DEBUG] Using scripts-root: F:\projects\git.vcpkg\scripts [DEBUG] Using builtin-registry: F:\projects\git.vcpkg\versions [DEBUG] Using downloads-root: F:\projects\git.vcpkg\downloads [DEBUG] Could not use IsWow64Process2, trying IsWow64Process Computing installation plan... [DEBUG] Found path: C:\Program Files\CMake\bin\cmake.exe [DEBUG] 1000: CreateProcessW("C:\Program Files\CMake\bin\cmake.exe" --version) [DEBUG] 1000: cmd_execute_and_stream_data() returned 0 after 45682 us [DEBUG] 1001: CreateProcessW("C:\Program Files\CMake\bin\cmake.exe" -DVCPKG_ROOT_DIR=F:/projects/git.vcpkg -DPACKAGES_DIR=F:/projects/git.vcpkg/packages -DBUILDTREES_DIR=F:/projects/git.vcpkg/buildtrees -D_VCPKG_INSTALLED_DIR=F:/projects/git.vcpkg/installed -DDOWNLOADS=F:/projects/git.vcpkg/downloads -DVCPKG_MANIFEST_INSTALL=OFF -P "F:\projects\git.vcpkg\buildtrees\0.vcpkg_tags.cmake") [DEBUG] 1001: cmd_execute_and_stream_data() returned 0 after 33275 us The following packages will be built and installed: libjpeg-turbo:x64-windows -> 3.0.1 * vcpkg-cmake:x64-windows -> 2023-05-04 * vcpkg-cmake-config:x64-windows -> 2022-02-06#1 Additional packages (*) will be modified to complete this operation. [DEBUG] 1002: CreateProcessW("C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -all -prerelease -legacy -products * -format xml) [DEBUG] 1002: cmd_execute_and_stream_data() returned 0 after 29307 us [DEBUG] Trying to hash F:\projects\git.vcpkg\scripts\toolchains/windows.cmake [DEBUG] F:\projects\git.vcpkg\scripts\toolchains/windows.cmake has hash e36df1c7f50ab25f9c182fa927d06c19ae082e0d599f132b3f655784b49e4b33 [DEBUG] Trying to hash F:\projects\git.vcpkg\triplets\x64-windows.cmake [DEBUG] F:\projects\git.vcpkg\triplets\x64-windows.cmake has hash 4556164a2cd3dd6f4742101eabb46def7e71b6e5856faa88e5d005aac12a803c Detecting compiler hash for triplet x64-windows... [DEBUG] Found path: C:\dev\Git\cmd\git.exe [DEBUG] 1003: CreateProcessW("C:\dev\Git\cmd\git.exe" --version) [DEBUG] 1003: cmd_execute_and_stream_data() returned 0 after 39611 us [DEBUG] Could not use IsWow64Process2, trying IsWow64Process A suitable version of powershell-core was not found (required v7.2.11) Downloading portable powershell-core 7.2.11... Downloading powershell-core... https://github.com/PowerShell/PowerShell/releases/download/v7.2.11/PowerShell-7.2.11-win-x86.zip->F:\projects\git.vcpkg\downloads\PowerShell-7.2.11-win-x86.zip Downloading https://github.com/PowerShell/PowerShell/releases/download/v7.2.11/PowerShell-7.2.11-win-x86.zip [DEBUG] Trying to hash F:\projects\git.vcpkg\downloads\PowerShell-7.2.11-win-x86.zip.12076.part [DEBUG] F:\projects\git.vcpkg\downloads\PowerShell-7.2.11-win-x86.zip.12076.part has hash e9581122101ad161ad628a6feb63e61d3ef8f064a3f325465e8a1a4a6cfc1affbc9bf63146efae0aa65ff9ea5c93018af2c413dc0940f0d162edef805659ec84 Extracting powershell-core... [DEBUG] 1004: CreateProcessW("C:\Program Files\CMake\bin\cmake.exe" -E tar xzf "F:\projects\git.vcpkg\downloads\PowerShell-7.2.11-win-x86.zip") [DEBUG] 1004: cmd_execute() returned (error: calling CreateProcessW failed with 1450 (������������ ��������� �������� ��� ���������� ��������.)) after 2857 us 'CMake' failed while extracting F:\projects\git.vcpkg\downloads\PowerShell-7.2.11-win-x86.zip. [DEBUG] D:\a\_work\1\s\src\vcpkg\archives.cpp(323): [DEBUG] Time in subprocesses: 150732us [DEBUG] Time in parsing JSON: 116us [DEBUG] Time in JSON reader: 399us [DEBUG] Time in filesystem: 2422us [DEBUG] Time in loading ports: 1576us [DEBUG] Exiting after 19 s (19398887us)

vcpkg install libjpeg-turbo --triplet x64-windows in Git Bash: works fine!

I executed

git clean -dfx
bootstrap-vcpkg.bat

before each test.

@greenozon
Copy link

latest bits are still failing in my case:

...
[DEBUG] 1005: cmd_execute() returned (error: calling CreateProcessW failed with 1450 (unknown error)) after 4949 us
...

@BillyONeal
Copy link
Member

@HappySeaFox @greenozon Are these both Windows 7?

@HappySeaFox
Copy link
Contributor Author

@BillyONeal Yes it's Win7 in my case.

@greenozon
Copy link

as well, w7 x64 SP1

@BillyONeal BillyONeal changed the title Fresh install: 'CMake' failed while extracting Windows 7: 'CMake' failed while extracting Nov 22, 2023
@SunBlack
Copy link
Contributor

SunBlack commented Jan 5, 2024

I had the same issue (but with powershell-core). Reverting from CMake 2.8.1 to 2.7.9 solved the issue.

@SamVanheer
Copy link

SamVanheer commented Jan 8, 2024

I'm getting the same problem as SunBlack. The latest vcpkg at commit ce46ba8 with a fresh setup and CMake 3.28.1 keeps giving the "failed while extracting" error. Reverting to CMake 3.27.9 fixes the problem.

I'm running up-to-date Windows 11. Is any other information needed?

@virtuozo007
Copy link

virtuozo007 commented Jan 11, 2024

@BillyONeal I had the same issue too when installing any packages.
For example: vcpkg install fontconfig:x64-windows, it says:

......
Downloading https://www.7-zip.org/a/7z2301-extra.7z
Extracting 7zip...
'CMake' failed while extracting D:\Libs\vcpkg\downloads\7z2301-extra.7z.

I am using VS2019, on Windows 7 SP1. with powershell 7.2.17.
And if i switch to 2023.08.09 version, it works fine.
All versions newer than that don't work.

if I install the package with --debug:

......
[DEBUG] Default binary cache path is: C:\Users\Leo\AppData\Local\vcpkg\archives
A suitable version of 7zip was not found (required v23.1.0) Downloading portable
 7zip 23.1.0...
[DEBUG] Trying to hash D:\Libs\vcpkg\downloads\7z2301-extra.7z
[DEBUG] D:\Libs\vcpkg\downloads\7z2301-extra.7z has hash c849c2cb489cf5b6eeb92bf
bc27dcb37d0349c36971e1bc7ef32c7cde1b659e19e8b46d734ba90f47affe07fdfd5b4774cbfa0f
df4b681e9f60bb46bba1f7f9b
Extracting 7zip...
[DEBUG] 1009: CreateProcessW("D:\Libs\vcpkg\downloads\tools\cmake-3.27.1-windows
\cmake-3.27.1-windows-i386/bin/cmake.exe" -E tar xzf "D:\Libs\vcpkg\downloads\7z
2301-extra.7z")
[DEBUG] Failed to write to stdout: 31

and at the same time, the dialog bellow shows up, saying that the vcpkg.exe has stopped working...
image

There is an empty folder named "7zip-23.01-windows.partial.5768" be created in the "vcpkg\downloads\tools" dir.
image

But the " "D:\Libs\vcpkg\downloads\tools\cmake-3.27.1-windows
\cmake-3.27.1-windows-i386/bin/cmake.exe" -E tar xzf "D:\Libs\vcpkg\downloads\7z
2301-extra.7z" " command can successfully be run in the console, the 7zip files can be extracted correctly.
That's very strange.

@HappySeaFox HappySeaFox changed the title Windows 7: 'CMake' failed while extracting 'CMake' failed while extracting Jan 14, 2024
@SamVanheer
Copy link

SamVanheer commented Jan 22, 2024

I did some testing and when running vcpkg with --debug added to VCPKG_INSTALL_OPTIONS the problem seems to become clear:

A suitable version of 7zip was not found (required v23.1.0) Downloading portable 7zip 23.1.0...

[DEBUG] Trying to hash C:\Users\User\Documents\Documents\GitHub\vcpkg_dev\test\vcpkg\downloads\7z2301-extra.7z

[DEBUG] C:\Users\User\Documents\Documents\GitHub\vcpkg_dev\test\vcpkg\downloads\7z2301-extra.7z has hash c849c2cb489cf5b6eeb92bfbc27dcb37d0349c36971e1bc7ef32c7cde1b659e19e8b46d734ba90f47affe07fdfd5b4774cbfa0fdf4b681e9f60bb46bba1f7f9b
Extracting 7zip...

[DEBUG] 1000: CreateProcessW("C:\Program Files\CMake\bin\cmake.exe" --version)

[DEBUG] 1000: cmd_execute_and_stream_data() returned 0 after    18127 us

[DEBUG] 1001: CreateProcessW("C:\Program Files\CMake\bin\cmake.exe" -E tar xzf "C:\Users\User\Documents\Documents\GitHub\vcpkg_dev\test\vcpkg\downloads\7z2301-extra.7z")

[DEBUG] 1001: cmd_execute() returned (error: calling CreateProcessW failed with 87 (The parameter is incorrect.)) after 78 us
'CMake' failed while extracting C:\Users\User\Documents\Documents\GitHub\vcpkg_dev\test\vcpkg\downloads\7z2301-extra.7z.

The command to extract the file seems to come from here: https://github.com/microsoft/vcpkg-tool/blob/710a3116bbd615864eef5f9010af178034cb9b44/src/vcpkg/archives.cpp#L316-L328

Digging through the calls the problem seems to be happening here: https://github.com/microsoft/vcpkg-tool/blob/710a3116bbd615864eef5f9010af178034cb9b44/src/vcpkg/base/system.process.cpp#L760-L773

One of the parameters passed in to CreateProcessW must be invalid here.

Running the extract command directly works just fine so CMake itself doesn't seem to be at fault here, unless some property of the executable changed in a way that causes CreateProcessW to fail now.

The --version command works fine as well so there must be something special about the extract command that's causing this.

Using a shorter path to the Git repository does not stop this from happening.

Sidenote: CMake's tar command doesn't have an f option. It's probably not a problem, but it should probably be removed unless the tool name can change.


Relevant info:
Operating system: Windows 11
CMake version: 3.28.1
vcpkg commit: fa6e6a6 (latest as of this writing)
vcpkg tool version: fresh build from new Git repository

@SamVanheer
Copy link

SamVanheer commented Jan 23, 2024

I built vcpkg.exe myself to see what's causing the problem. I've pinpointed it to this: https://github.com/microsoft/vcpkg-tool/blob/710a3116bbd615864eef5f9010af178034cb9b44/src/vcpkg/base/system.process.cpp#L1331-L1336

auto maybe_error = proc_attribute_list.update_attribute(
    PROC_THREAD_ATTRIBUTE_HANDLE_LIST, handles_to_inherit, number_of_handles * sizeof(HANDLE));
if (!maybe_error.has_value())
{
    return maybe_error.error();
}

Commenting out this code allows the process to be created successfully.

I printed out the handle values as integers to see what's going on:

constexpr size_t number_of_candidate_handles = 3;
HANDLE handles_to_inherit[number_of_candidate_handles] = {
    GetStdHandle(STD_INPUT_HANDLE), GetStdHandle(STD_OUTPUT_HANDLE), GetStdHandle(STD_ERROR_HANDLE)};
//Util::sort(handles_to_inherit);
size_t number_of_handles =
    std::unique(handles_to_inherit, handles_to_inherit + number_of_candidate_handles) - handles_to_inherit;

Debug::println(fmt::format("number of handles: {}", number_of_handles));

for (int i = 0; i < 3; ++i)
{
    Debug::println(fmt::format("handle {}: {:x}", i, (uintptr_t)handles_to_inherit[i]));
}

This printed:

[DEBUG] number of handles: 3

[DEBUG] handle 0: ffffffffffffffff
[DEBUG] handle 1: abc
[DEBUG] handle 2: bb0

Standard input's value is INVALID_HANDLE_VALUE. Calling GetLastError returns 6, which is ERROR_INVALID_HANDLE.

My guess is that CMake 3.28 is making the handle invalid somehow. Perhaps a change in how CMake handles execute_process accidentally broke the handling of standard input handle inheritance?

Looking at CMake's history for that command i can see one change that might be the cause: https://gitlab.kitware.com/cmake/cmake/-/commit/5420639a8d696055577de638e0952d6936706f18

The way standard input is set might be incorrect here:

builder.SetExternalStream(cmUVProcessChainBuilder::Stream_INPUT,  cm_fileno(stdin));

Note how output and error streams use a different function:

builder.SetBuiltinStream(cmUVProcessChainBuilder::Stream_OUTPUT);

However the code to set a builtin input stream has this:

// FIXME

To confirm this i used INPUT_FILE to override the input handle:

execute_process(
	INPUT_FILE "foo.txt"
    COMMAND "${Z_VCPKG_EXECUTABLE}" install
        --triplet "${VCPKG_TARGET_TRIPLET}"
        --vcpkg-root "${Z_VCPKG_ROOT_DIR}"
        "--x-wait-for-lock"
        "--x-manifest-root=${VCPKG_MANIFEST_DIR}"
        "--x-install-root=${_VCPKG_INSTALLED_DIR}"
        ${Z_VCPKG_FEATURE_FLAGS}
        ${Z_VCPKG_ADDITIONAL_MANIFEST_PARAMS}
        ${VCPKG_INSTALL_OPTIONS}
    OUTPUT_VARIABLE Z_VCPKG_MANIFEST_INSTALL_LOGTEXT
    ERROR_VARIABLE Z_VCPKG_MANIFEST_INSTALL_LOGTEXT
    RESULT_VARIABLE Z_VCPKG_MANIFEST_INSTALL_RESULT
    ${Z_VCPKG_MANIFEST_INSTALL_ECHO_PARAMS}
)

The file foo.txt exists next to vcpkg.cmake and is is empty.

Running CMake with that works (using freshly downloaded vcpkg, not my local build):

A suitable version of 7zip was not found (required v23.1.0) Downloading portable 7zip 23.1.0...
Downloading 7zip...
https://www.7-zip.org/a/7z2301-extra.7z->C:\vcpkg_dev\test\vcpkg\downloads\7z2301-extra.7z

Downloading https://www.7-zip.org/a/7z2301-extra.7z

[DEBUG] Trying to hash C:\vcpkg_dev\test\vcpkg\downloads\7z2301-extra.7z.18452.part

[DEBUG] C:\vcpkg_dev\test\vcpkg\downloads\7z2301-extra.7z.18452.part has hash c849c2cb489cf5b6eeb92bfbc27dcb37d0349c36971e1bc7ef32c7cde1b659e19e8b46d734ba90f47affe07fdfd5b4774cbfa0fdf4b681e9f60bb46bba1f7f9b

Extracting 7zip...

[DEBUG] 1000: CreateProcessW("C:\Program Files\CMake\bin\cmake.exe" --version)

[DEBUG] 1000: cmd_execute_and_stream_data() returned 0 after    18248 us

[DEBUG] 1001: CreateProcessW("C:\Program Files\CMake\bin\cmake.exe" -E tar xzf "C:\vcpkg_dev\test\vcpkg\downloads\7z2301-extra.7z")

[DEBUG] 1001: cmd_execute() returned 0 after 160728 us

Total install time: 1.9 us

I checked again and the handle is valid this time around.

I've reported this bug on the CMake issue tracker here: https://gitlab.kitware.com/cmake/cmake/-/issues/25625

@HappySeaFox
Copy link
Contributor Author

@SamVanheer Thanks for the great investigation!

I've just cloned a fresh copy of vcpkg and installed CMake 3.23.4. I experience the same problem, so I guess it's not 3.28-specific.

[DEBUG] To include the environment variables in debug output, pass --debug-env
[DEBUG] Trying to load bundleconfig from F:\projects\git.vcpkg.test\vcpkg-bundle.json
[DEBUG] Failed to open: F:\projects\git.vcpkg.test\vcpkg-bundle.json
[DEBUG] Bundle config: readonly=false, usegitregistry=false, embeddedsha=nullopt, deployment=Git, vsversion=nullopt
[DEBUG] Metrics enabled.
[DEBUG] Feature flag 'binarycaching' unset
[DEBUG] Feature flag 'compilertracking' unset
[DEBUG] Feature flag 'registries' unset
[DEBUG] Feature flag 'versions' unset
[DEBUG] Feature flag 'dependencygraph' unset
[DEBUG] Using scripts-root: F:\projects\git.vcpkg.test\scripts
[DEBUG] Using builtin-ports: F:\projects\git.vcpkg.test\ports
[DEBUG] Using installed-root: F:\projects\git.vcpkg.test\installed
[DEBUG] Using buildtrees-root: F:\projects\git.vcpkg.test\buildtrees
[DEBUG] Using packages-root: F:\projects\git.vcpkg.test\packages
[DEBUG] Using vcpkg-root: F:\projects\git.vcpkg.test
[DEBUG] Using scripts-root: F:\projects\git.vcpkg.test\scripts
[DEBUG] Using builtin-registry: F:\projects\git.vcpkg.test\versions
[DEBUG] Using downloads-root: F:\projects\git.vcpkg.test\downloads
[DEBUG] Could not use IsWow64Process2, trying IsWow64Process
Computing installation plan...
[DEBUG] Loading dep info for: libpng:x64-windows sail:x64-windows
[DEBUG] Found path: C:\Program Files\CMake\bin\cmake.exe
[DEBUG] 1000: CreateProcessW("C:\Program Files\CMake\bin\cmake.exe" --version)
[DEBUG] 1000: cmd_execute_and_stream_data() returned 0 after    87348 us
[DEBUG] 1001: CreateProcessW("C:\Program Files\CMake\bin\cmake.exe" --version)
[DEBUG] 1001: cmd_execute_and_stream_data() returned 0 after    85120 us
A suitable version of cmake was not found (required v3.27.1) Downloading portable cmake 3.27.1...
Downloading cmake...
https://github.com/Kitware/CMake/releases/download/v3.27.1/cmake-3.27.1-windows-i386.zip->F:\projects\git.vcpkg.test\downloads\cmake-3.27.1-windows-i386.zip
Downloading https://github.com/Kitware/CMake/releases/download/v3.27.1/cmake-3.27.1-windows-i386.zip
[DEBUG] Trying to hash F:\projects\git.vcpkg.test\downloads\cmake-3.27.1-windows-i386.zip.8316.part
[DEBUG] F:\projects\git.vcpkg.test\downloads\cmake-3.27.1-windows-i386.zip.8316.part has hash a847f636fb27ba41ba9e6eaafa56937c614bcb39c6d0c9723241c229a9b0a77b4d00ebee88639561035d43f9aa64895f387eab56c628990c01191da57839cda0
Extracting cmake...
[DEBUG] Found path: C:\Program Files\CMake\bin\cmake.exe
[DEBUG] 1002: CreateProcessW("C:\Program Files\CMake\bin\cmake.exe" -E tar xzf "F:\projects\git.vcpkg.test\downloads\cmake-3.27.1-windows-i386.zip")
[DEBUG] 1002: cmd_execute() returned (error: calling CreateProcessW failed with 1450 (Недостаточно системных ресурсов для завершения операции.)) after 992 us
'CMake' failed while extracting F:\projects\git.vcpkg.test\downloads\cmake-3.27.1-windows-i386.zip.
[DEBUG] D:\a\_work\1\s\src\vcpkg\archives.cpp(323): 
[DEBUG] Time in subprocesses: 173460us
[DEBUG] Time in parsing JSON: 640us
[DEBUG] Time in JSON reader: 818us
[DEBUG] Time in filesystem: 23640us
[DEBUG] Time in loading ports: 11680us
[DEBUG] Exiting after 8.3 s (8059194us)
> cmake --version
cmake version 3.23.4

@SamVanheer
Copy link

You're getting error 1450 when vcpkg calls CreateProcessW. That error is ERROR_NO_SYSTEM_RESOURCES, "Insufficient system resources exist to complete the requested service".

Both result in the same error message (failed while extracting) but the cause is completely different. Error 1450 is most likely caused by a problem with the local system rather than vcpkg or CMake. I searched for the error code and found that there could be several causes like the system running out of memory or disk space.

Given that you're running Windows 7 this may be caused by vcpkg relying on something that only newer versions of Windows can do, but i've no way to determine this.

You reported that older versions of vcpkg work so you could try checking which change causes the problem by finding the last working version and the first broken version, and then checking the changes made in-between until you find the commit where it first manifests the problem. You'll have to clone vcpkg-tool and build it locally to do this and jump back to older commits with Git.

Once you've found the commit it should be as simple as checking which changes were made. The cause is possibly the use of a Win32 API that has version-specific requirements or behavior but the cause may be at the start of a long chain of function calls that eventually pass data into a Win32 function.

Since i'm not getting this error (i'm on Windows 11) i can't do this myself.

@HappySeaFox
Copy link
Contributor Author

Cannot build vcpkg-tool locally due to numerous

error C2370: 'vcpkg::all_define_metrics': redefinition; different storage class

errors. Tried the latest master and the 2023-08-09 tag. My MSVC is 2019.

@SamVanheer
Copy link

This happens because vcpkg has a lot of declarations that use extern const that are defined with constexpr which the 2019 compiler doesn't allow by default.

There is a compiler setting to allow for the correct behavior which is described here: https://learn.microsoft.com/en-us/cpp/build/reference/zc-externconstexpr?view=msvc-170

I tested it with 2019 and it does build with this setting enabled. 2022 enables this behavior through the /permissive- option which is the default.

I don't know which version of VS you're supposed to use when building vcpkg (should really be mentioned somewhere), perhaps there is a need to set that option in its CMakeLists.txt to make sure it still compiles properly when using older compilers.

@SamVanheer
Copy link

SamVanheer commented Jan 25, 2024

The problem in CMake is fixed and should be working correctly starting with version 3.28.2.

Based on some of the reports in this issue it's possible for vcpkg itself to encounter the same problem where the standard stream handles are invalid.

The CRT won't open the streams if there is no console: https://github.com/huangqinjin/ucrt/blob/f941b374deb33b1bce9c8d7e3064c7b652d172c4/stdio/_file.cpp#L97-L109

If vcpkg is launched without a console any processes created using cmd_execute_impl on Windows could inherit invalid handles which could cause error 87 to occur. I think there are multiple ways to solve this problem:

  1. check the streams when vcpkg starts and open them with dummy input/output so the handles are always valid regardless of how vcpkg is launched
  2. Filter out invalid handles in cmd_execute_impl

So, from what i can see there are 3 different causes of the "failed while extracting" error:

  1. CMake passing invalid handles (fixed)
  2. vcpkg starting with invalid/no handles
  3. Unknown cause that seems to happen on older versions of Windows resulting in error 1450

Note that users started getting error 1450 in the first vcpkg release after the one that started passing vcpkg's stdin handles to subprocesses: microsoft/vcpkg-tool@81c8bed

CMake changed how they pass handles starting with version 3.28 which is months after this problem was first reported so i doubt that is related to error 1450. But perhaps handle inheritance behavior was already broken on Windows 7 starting with vcpkg version 2023-09-15 because of this change in vcpkg itself?

The fastest way to find out would be to build vcpkg from the latest commit with handle inheritance disabled (note: you must also disable the attribute list being passed in according to this article) and then testing if it works. If it does, then something is going wrong with explicit handle inheritance on Windows 7.

I compared the current code with the article i linked and it looks just about the same, so it seems unlikely that this change is responsible but i can't test this myself due since i'm not getting that error myself. Anybody who is experiencing it should be able to test it using a custom built vcpkg.

If this isn't the cause then pinpointing the commit that introduces the problem is the way to identify the actual cause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:vcpkg-bug The issue is with the vcpkg system (including helper scripts in `scripts/cmake/`)
Projects
None yet
Development

Successfully merging a pull request may close this issue.