0
votes

I configured a CMAKE based build, via vsagent on windows, that was running great until very recently. It started failing with the following error:

Updated with debug output

============================================================================== Task : CMake Description : Build with the CMake cross-platform build system Version : 1.0.25 Author : Microsoft Corporation

Help : More Information

agent.workFolder=C:\vsagent_work loading inputs and endpoints loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION loading INPUT_CMAKEARGS loading INPUT_CWD loaded 5 check path : C:\vsagent_work_tasks\CMake_7d831c3c-3c68-459a-a5c9-bde6e659596c\1.0.25\task.json set resource file to: C:\vsagent_work_tasks\CMake_7d831c3c-3c68-459a-a5c9-bde6e659596c\1.0.25\task.json system.culture=en-US Absolute path for pathSegments: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.10.25017\bin\HostX86\x86/cmake = C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.10.25017\bin\HostX86\x86\cmake Absolute path for pathSegments: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VC\VCPackages/cmake = C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VC\VCPackages\cmake Absolute path for pathSegments: C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.1/cmake = C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.1\cmake Absolute path for pathSegments: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow/cmake = C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\cmake Absolute path for pathSegments: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer/cmake = C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\cmake Absolute path for pathSegments: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin\Roslyn/cmake = C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin\Roslyn\cmake Absolute path for pathSegments: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Team Tools\Performance Tools/cmake = C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Team Tools\Performance Tools\cmake Absolute path for pathSegments: C:\Program Files (x86)\Microsoft Visual Studio\Shared\Common\VSPerfCollectionTools/cmake = C:\Program Files (x86)\Microsoft Visual Studio\Shared\Common\VSPerfCollectionTools\cmake Absolute path for pathSegments: C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools/cmake = C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\cmake Absolute path for pathSegments: C:\Program Files (x86)\Windows Kits\10\bin\x86/cmake = C:\Program Files (x86)\Windows Kits\10\bin\x86\cmake Absolute path for pathSegments: C:\Program Files (x86)\Windows Kits\10\bin\10.0.14393.0\x86/cmake = C:\Program Files (x86)\Windows Kits\10\bin\10.0.14393.0\x86\cmake Absolute path for pathSegments: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin/cmake = C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin\cmake Absolute path for pathSegments: C:\Windows\Microsoft.NET\Framework\v4.0.30319/cmake = C:\Windows\Microsoft.NET\Framework\v4.0.30319\cmake Absolute path for pathSegments: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE/cmake = C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\cmake Absolute path for pathSegments: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\Tools/cmake = C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\Tools\cmake Absolute path for pathSegments: C:\vsagent\externals\git\cmd/cmake = C:\vsagent\externals\git\cmd\cmake Absolute path for pathSegments: C:\WINDOWS\system32/cmake = C:\WINDOWS\system32\cmake Absolute path for pathSegments: C:\WINDOWS/cmake = C:\WINDOWS\cmake Absolute path for pathSegments: C:\WINDOWS\System32\Wbem/cmake = C:\WINDOWS\System32\Wbem\cmake Absolute path for pathSegments: C:\WINDOWS\System32\WindowsPowerShell\v1.0/cmake = C:\WINDOWS\System32\WindowsPowerShell\v1.0\cmake Absolute path for pathSegments: C:\ProgramData\chocolatey\bin/cmake = C:\ProgramData\chocolatey\bin\cmake Absolute path for pathSegments: C:\Program Files\Git\cmd/cmake = C:\Program Files\Git\cmd\cmake Absolute path for pathSegments: C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit/cmake = C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\cmake Absolute path for pathSegments: C:\Program Files\Microsoft SQL Server\130\Tools\Binn/cmake = C:\Program Files\Microsoft SQL Server\130\Tools\Binn\cmake Absolute path for pathSegments: C:\Program Files\dotnet/cmake = C:\Program Files\dotnet\cmake Absolute path for pathSegments: C:\tools\go\bin/cmake = C:\tools\go\bin\cmake Absolute path for pathSegments: c:\vsagent\scripts/cmake = c:\vsagent\scripts\cmake Absolute path for pathSegments: "C:\Program Files\CMake\bin"/cmake = C:\vsagent_work\1\s\"C:\Program Files\CMake\bin"\cmake Absolute path for pathSegments: C:\WINDOWS\ServiceProfiles\NetworkService\AppData\Local\Microsoft\WindowsApps/cmake = C:\WINDOWS\ServiceProfiles\NetworkService\AppData\Local\Microsoft\WindowsApps\cmake Absolute path for pathSegments: C:\vsagent\bin/cmake = C:\vsagent\bin\cmake Absolute path for pathSegments: C:\vsagent\bin/cmake = C:\vsagent\bin\cmake Absolute path for pathSegments: cmake = C:\vsagent_work\1\s\cmake check path : C:\vsagent_work\1\s\cmake cmake=C:\vsagent_work\1\s\cmake cwd=C:\vsagent_work\1\s\build testing directory 'C:\vsagent_work\1\s\build' testing directory 'C:\vsagent_work\1\s' mkdir 'C:\vsagent_work\1\s\build' cmakeArgs=.. -DCMAKE_TOOLCHAIN_FILE=C:\src\misc\vcpkg\scripts\buildsystems\vcpkg.cmake -DCMAKE_BUILD_TYPE=Debug -G "Visual Studio 15 2017 Win64" C:\vsagent_work\1\s\cmake arg: .. -DCMAKE_TOOLCHAIN_FILE=C:\src\misc\vcpkg\scripts\buildsystems\vcpkg.cmake -DCMAKE_BUILD_TYPE=Debug -G "Visual Studio 15 2017 Win64" exec tool: C:\vsagent_work\1\s\cmake Arguments: .. -DCMAKE_TOOLCHAIN_FILE=C:\src\misc\vcpkg\scripts\buildsystems\vcpkg.cmake -DCMAKE_BUILD_TYPE=Debug -G Visual Studio 15 2017 Win64 C:\vsagent_work\1\s\cmake .. -DCMAKE_TOOLCHAIN_FILE=C:\src\misc\vcpkg\scripts\buildsystems\vcpkg.cmake -DCMAKE_BUILD_TYPE=Debug -G Visual Studio 15 2017 Win64 C:\vsagent_work\1\s\cmake failed. spawn C:\vsagent_work\1\s\cmake ENOENT Processed: ##vso[task.issue type=error;]C:\vsagent_work\1\s\cmake failed. spawn C:\vsagent_work\1\s\cmake ENOENT task result: Failed CMake failed with error: C:\vsagent_work\1\s\cmake failed. spawn C:\vsagent_work\1\s\cmake ENOENT Processed: ##vso[task.issue type=error;]CMake failed with error: C:\vsagent_work\1\s\cmake failed. spawn C:\vsagent_work\1\s\cmake ENOENT Processed: ##vso[task.complete result=Failed;]CMake failed with error: C:\vsagent_work\1\s\cmake failed. spawn C:\vsagent_work\1\s\cmake ENOENT rc:-4058 success:false

The problem is that it is trying to run:

[command]C:\vsagent_work\6\s\cmake

The last build that worked was running a different command:

[command]c:\program files\cmake\bin\cmake.exe

Both builds were running vsagent version 2.114.0. Both builds were running CMAKE Task version 1.0.25. There were no build configuration changes between these two builds. Perhaps an OS update was installed, but I can't find anything in the update history.

It turns out that before the build failures cmake was not in the system PATH. It was in the user PATH of the user that installed vsagent. I added the cmake directory to the system PATH after the failures started, but that did not make any difference. The current PATH listed in the capabilities for the build agent is:

C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\ProgramData\chocolatey\bin;C:\Program Files\Git\cmd;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\dotnet\;C:\tools\go\bin;c:\vsagent\scripts;"C:\Program Files\CMake\bin";C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Microsoft\WindowsApps;C:\vsagent\bin

As a last data point, we do have a cmake directory at the root of our repo, so c:\vsagent_work\6\s\cmake is a directory on disk.

Does anyone have any idea what might have changed or any ideas on how to diagnose the issue? Why isn't vsagent using cmake from the system PATH?

Update: I've reinstalled the agent and it is now at version 2.120.1

1
Try to setup a new build agent on this machine, then queue build with this agent and check the result.starian chen-MSFT
Queue a build with "system.debug" variable set to "true" and then share the build logs for cmake step here. And can you also check the capabilities settings of the build agent?Eddie Chen - MSFT
I've updated the question with debug output. I also upgraded the agent and still repro the problem. What would you like me to check in the capabilities?Rich Randall

1 Answers

0
votes

It's the quotes around

"c:\program files\cmake\bin"

in the PATH variable that causes the problem. path.resolve() turns this in to

C:\vsagent\_work\1\s\"C:\Program Files\CMake\bin"

when

C:\vsagent\_work\1\s

is the current working directory. Removing the quotes fixes the issue.

There is also a bug at https://github.com/Microsoft/vsts-task-lib/blob/d487d3a0eb602c207bb4c0cf77064ed7df51fbac/node/lib/task.ts#L656 . The call to

stats(tool).isFile

should end in '()' since isFile is a function. Because there is a 'cmake' directory in the current working directory, the lack of parens causes the if statement to resolve to true.