Reputation: 107
A machine building a C++ project solution in Visual Studio erroneously generates the following error:
Error executing C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\bin\Hostx64\x64\cl.exe (tool returned code: 2)
[106/749] Compile [x64] cl : Command line error D8037 : cannot create temporary il file; clean temp directory of old il files (0:00.09 at +0:00)
The message itself is erroneous, despite Microsoft's documentation, as the machine's %TMP%
folder contains none such files mentioned and lots of disk space is available. The machine runs a completely fresh install of Windows 11 and is only configured to run builds for this project and nothing else. Other machines with an identical setup compiles the project without problems.
As this is a completely fresh Windows install, I have verified that the %TMP%
environment path points to an existing folder (as expected located in AppData
) with adequate permissions and that all other environment variables are pointing correctly.
I am unable to provide a minimal reproducible example since I don't understand why this is happening, however I have debugged the situation to provide the following information:
Using ProcMon when executing the build reveals the the CreateFileMapping
operation called from msvcp140.dll
returns a "FILE LOCKED WITH ONLY READERS" message, no other information is provided.
By setting cl.exe
to "Run this program as an administrator" the build can be executed, however this of course generates loads of UAC prompts and is not a viable solution. Disabling UAC will allow the operation to fully build, with the added caveat of new command prompt windows being generated for each module built with cl.exe
.
Building the solution using the "Run Build Insights" rebuild option in Visual Studio will cause the project to build normally, and running additional builds pass without any issues. This is however not a viable solution as the project needs to build without this bypass.
Everything seems to point to a permission error, whereas cl.exe
is for some reason unable to write files to the system's %TMP%
folder. This is supported by the run build insights workaround, as that type of build supposedly instantiates its own developer environment with a separate temp folder.
Upvotes: 6
Views: 104
Reputation: 107
This problem was related to the installation of Incredibuild. It is still unclear to me as to what exactly the root cause was but with Incredibuild installed it is possible that the compilation engaged Incredibuild erroneously, causing the permission problem as stated. At the time of writing this, there is likely some configuration issue with the Visual Studio Installer release of Incredibuild in combination with the stated compiler version.
Uninstalling Incredibuild via the Visual Studio Installer resolved the issue and allowed everything to compile normally again. Hopefully anyone else experiencing this problem will find this answer.
Upvotes: 3