vscode-cmake-tools icon indicating copy to clipboard operation
vscode-cmake-tools copied to clipboard

[Bug] Task defined inside workspace file can not be run, it is stuck in "Task is running" state.

Open nadiaivc opened this issue 6 months ago • 3 comments

Brief Issue Summary

If the task is defined in workspace file, it is stuck with error:

[error] TypeError: Cannot read properties of undefined (reading 'path')
	at CustomBuildTaskTerminal.getProject (<home>\.vscode\extensions\ms-vscode.cmake-tools-1.21.36\dist\main.js:87896:80)

Seems the problem with workspaceFolder.uri. The task example: <...>.code-workspace:

{
  "launch": {
    "version": "0.2.0",
    "configurations": [
     <...>
    ],
  },
  "tasks": {
    "version": "2.0.0",
    "tasks": [
      {
        "type": "cmake",
        "label": "Prelaunch Build",
        "command": "build",
        "targets": [
          "all"
        ],
      }
    ]
  },
  "folders": [
    {
      "path": "."
    }
  ],
}

If the task is replaced into tasks.json, the workspace folder is recognized and everything works correctly

CMake Tools Diagnostics

{
  "os": "win32",
  "vscodeVersion": "1.95.3",
  "cmtVersion": "1.22.2",
  "configurations": [
    {
      "folder": "<>",
      "cmakeVersion": "3.26.4",
      "configured": true,
      "generator": "Ninja",
      "usesPresets": false,
      "compilers": {}
    }
  ],
  "cpptoolsIntegration": {
    "isReady": true,
    "hasCodeModel": true,
    "activeBuildType": "Debug",
    "buildTypesSeen": [
      "Debug"
    ],
    "requests": [],
    "responses": [],
    "partialMatches": [],
    "targetCount": 1,
    "executablesCount": 1,
    "librariesCount": 0,
    "targets": [
      {
        "name": "main",
        "type": "EXECUTABLE"
      }
    ]
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": true
    }
  ]
}

Debug Log

ExtensionHost window (output window is empty):
[error] TypeError: Cannot read properties of undefined (reading 'path')
	at CustomBuildTaskTerminal.getProject (<>\.vscode\extensions\ms-vscode.cmake-tools-1.22.2\dist\main.js:87966:80)
	at CustomBuildTaskTerminal.runBuildTask (<>\.vscode\extensions\ms-vscode.cmake-tools-1.22.2\dist\main.js:88014:34)
	at CustomBuildTaskTerminal.open (<>\.vscode\extensions\ms-vscode.cmake-tools-1.22.2\dist\main.js:87876:28)
	at X0.startSendingEvents (file:///<>/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:114:40456)
	at Jw.S (file:///<>/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:114:44872)
	at Jw.attachPtyToTerminal (file:///<>/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:114:42916)
	at Qw.$onDidStartTask (file:///<>/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:121:52658)

Additional Information

No response

nadiaivc avatar Jul 31 '25 09:07 nadiaivc

Hi @nadiaivc , thank you for reporting this issue. We tried to check this issue in Visual Studio Code v1.102.3 + CMake Tools v1.22.2. But we can't reproduce this issue. Could you help to take a look at it? In order for us to investigate this further, could you please provide a sample project to us that can reproduce this issue? Thanks.

Image

yanghhhhhhh avatar Aug 01 '25 07:08 yanghhhhhhh

Hi @yanghhhhhhh , Thank you for your answer. To reproduce the issue it is necessary to move task from tasks,json to sample.code_workspace and the task type should be cmake. And then try to run "Run Task" in the same way. This scenario is necessary for using launch->preLaunchTask property, in this case the task should be placed inside workspace file. There is a simple example, you don't need any extra files, because cmake anyway will not start the build.

example.code-workspace.txt

nadiaivc avatar Aug 01 '25 09:08 nadiaivc

Hi @nadiaivc , thanks for reporting issue here! Reproduced this issue on VS Code 1.102.3 + CMake Tools v1.22.3 release version. Repro Steps: 1. Download the file example.code-workspace (example.code-workspace.txt). 2. Launch VS Code, open Workspace from File, choose the file example.code-workspace. 3. Press F1 and click "Tasks: Run Task" > "cmake" > "Prelaunch Build". 4. Observe the task process, open output (ExtensionHost window) window, observe the error message.

Details please see following video:

Image

FYI: @gcampbell-msft

yanghhhhhhh avatar Aug 04 '25 07:08 yanghhhhhhh