microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
23.24k stars 6.4k forks source link

Run vcvarsall.bat to get Visual Studio env failed #24272

Closed atraczyk closed 2 years ago

atraczyk commented 2 years ago

I am unable to build x64 packages with:

Packages build correctly on 2 other machines with Visual Studio 2019 16.11.11(with the same toolsets + SDKs, and additional components).

Environment

To Reproduce Steps to reproduce the behavior:

  1. ./vcpkg install libusb-win32:x64-windows --debug
  2. Fails with Run vcvarsall.bat to get Visual Studio env failed with exit code -1073740791

Expected behavior The package should build successfully.

Failure logs

[DEBUG] Feature flag 'binarycaching' unset
[DEBUG] Feature flag 'manifests' unset
[DEBUG] Feature flag 'compilertracking' unset
[DEBUG] Feature flag 'registries' unset
[DEBUG] Feature flag 'versions' unset
[DEBUG] Failed to open: C:\Projects\vcpkg\vcpkg-bundle.json
[DEBUG] Bundle config: readonly=0, usegitregistry=0, embeddedsha=nullopt
[DEBUG] Using builtin-ports: C:\Projects\vcpkg\ports
[DEBUG] Using installed-root: C:\Projects\vcpkg\installed
[DEBUG] Using buildtrees-root: C:\Projects\vcpkg\buildtrees
[DEBUG] Using packages-root: C:\Projects\vcpkg\packages
[DEBUG] Using scripts-root: C:\Projects\vcpkg\scripts
[DEBUG] Using vcpkg-root: C:\Projects\vcpkg
[DEBUG] Using scripts-root: C:\Projects\vcpkg\scripts
[DEBUG] Using builtin-registry: C:\Projects\vcpkg\versions
[DEBUG] Using downloads-root: C:\Projects\vcpkg\downloads
[DEBUG] Default binary cache path is: C:\Users\andréas tràczyk\AppData\Local\vcpkg\archives
Computing installation plan...
[DEBUG] Found path: C:\Program Files\CMake\bin\cmake.exe
[DEBUG] CreateProcessW("C:\Program Files\CMake\bin\cmake.exe" --version)
[DEBUG] ReadFile() finished with GetLastError(): 109
[DEBUG] 14588: cmd_execute_and_stream_data() returned 0 after    41333 us
[DEBUG] CreateProcessW("C:\Program Files\CMake\bin\cmake.exe" -DVCPKG_ROOT_DIR=C:/Projects/vcpkg -DPACKAGES_DIR=C:/Projects/vcpkg/packages -DBUILDTREES_DIR=C:/Projects/vcpkg/buildtrees -D_VCPKG_INSTALLED_DIR=C:/Projects/vcpkg/installed -DDOWNLOADS=C:/Projects/vcpkg/downloads -DVCPKG_MANIFEST_INSTALL=OFF -P "C:\Projects\vcpkg\buildtrees\0.vcpkg_tags.cmake")
[DEBUG] ReadFile() finished with GetLastError(): 109
[DEBUG] 14588: cmd_execute_and_stream_data() returned 0 after    27986 us
The following packages will be built and installed:
    sqlite3[core]:x86-windows -> 3.37.2#1
  * vcpkg-cmake[core]:x64-windows -> 2022-04-12
  * vcpkg-cmake-config[core]:x64-windows -> 2022-02-06
Additional packages (*) will be modified to complete this operation.
[DEBUG] CreateProcessW("C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -all -prerelease -legacy -products * -format xml)
[DEBUG] ReadFile() finished with GetLastError(): 109
[DEBUG] 14588: cmd_execute_and_stream_data() returned 0 after    21446 us
Detecting compiler hash for triplet x64-windows...
[DEBUG] Found path: C:\Program Files\Git\cmd\git.exe
[DEBUG] CreateProcessW("C:\Program Files\Git\cmd\git.exe" --version)
[DEBUG] ReadFile() finished with GetLastError(): 109
[DEBUG] 14588: cmd_execute_and_stream_data() returned 0 after    30111 us
[DEBUG] CreateProcessW("C:\Projects\vcpkg\downloads\tools\powershell-core-7.2.1-windows\pwsh.exe" --version)
[DEBUG] ReadFile() finished with GetLastError(): 109
[DEBUG] 14588: cmd_execute_and_stream_data() returned 0 after   150849 us
[DEBUG] CreateProcessW(cmd /c "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary/Build\vcvarsall.bat" -vcvars_ver=14.29.30133 amd64   2>&1 <NUL  & echo cdARN4xjKueKScMy9C6H & set)
[DEBUG] ReadFile() finished with GetLastError(): 109
[DEBUG] 14588: cmd_execute_and_stream_data() returned 3221226505 after   861633 us
Run vcvarsall.bat to get Visual Studio env failed with exit code -1073740791
[DEBUG] D:\a\_work\1\s\src\vcpkg\base\system.process.cpp(702):
[DEBUG] Time in subprocesses: 1133358 us
[DEBUG] Time in parsing JSON: 156 us
[DEBUG] Time in JSON reader: 128 us
[DEBUG] Time in filesystem: 6845 us
[DEBUG] Time in loading ports: 848 us
[DEBUG] Exiting after 1.173 s (1160574 us)

Is there a way to increase the verbosity of the logs?

Cheney-W commented 2 years ago

What's the result when you execute the following command in a new cmd window?

 "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary/Build\vcvarsall.bat" -vcvars_ver=14.2 amd64
  cl /Bv

If you still get the same error, please add set VSCMD_DEBUG=3 and run the below command: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary/Build\vcvarsall.bat" -vcvars_ver=14.2 amd64 > log.log

Then send the log.log to me. Thank you!

atraczyk commented 2 years ago

@Cheney-W Here's the output of cl /Bv after having run "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary/Build\vcvarsall.bat" -vcvars_ver=14.2 amd64:

Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30143 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

Compiler Passes:
 C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\cl.exe:        Version 19.29.30143.0
 C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\c1.dll:        Version 19.29.30143.0
 C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\c1xx.dll:      Version 19.29.30143.0
 C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\c2.dll:        Version 19.29.30143.0
 C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\c1xx.dll:      Version 19.29.30143.0
 C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\link.exe:      Version 14.29.30143.0
 C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\mspdb140.dll:  Version 14.29.30143.0
 C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\1033\clui.dll: Version 19.29.30143.0

cl : Command line error D8003 : missing source filename

And here's the log from the vcvarsall line using VSCMD_DEBUG=3: log.log

Thanks

Cheney-W commented 2 years ago

It looks like this issue cannot be reproduced with the command alone. Does this issue still occur when you clone a new vcpkg?

atraczyk commented 2 years ago

Yes. I've attempted a thorough clean of vcpkg references on my system. I get the same results. Perhaps there is some subtle breakage in my Visual Studio installation?

Cheney-W commented 2 years ago

Generally speaking, if vcvarsall.bat can run successfully on the ordinary cmd, it will not be a problem with the installation. But to be on the safe side, I think you can reinstall your Visual Studio. Also, I looked up the error return value online and it says it's a memory issue, is it possible that other software, like antivirus software or something, is causing this problem?

atraczyk commented 2 years ago

I'm not sure, but it is new and definitely related to some element present on the specific machine in question. I tried a reinstall but that didn't work. I bet there's a cache that's not cleared when uninstalling also. I'm gonna install VS 2022 and see what happens.

atraczyk commented 2 years ago

I searched for tickets related to:

[DEBUG] D:\a\_work\1\s\src\vcpkg\base\system.process.cpp(702):

and found https://github.com/microsoft/vcpkg/issues/13890, so I checked HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun and I found "C:\Program Files (x86)\clink\0.4.9\clink.bat" inject --autorun --profile ~\clink. After removing that, everything works as expected.

Cheney-W commented 2 years ago

Thanks for your reply! I'm glad to know this issue has been solved.

atraczyk commented 2 years ago

@Cheney-W Thanks for your help and time!