Skip to content

Unable to use the extension when cmake.sourceDirectory is a subdirectory #3121

@FtZPetruska

Description

@FtZPetruska

Brief Issue Summary

Starting version 1.14.29, the extension fails to work when the source directory is not the root of the workspace.

Whether the project is already configured or not, the CMake/Build tab in OUTPUT reads:

Unhandled exception: Failed to open CMake cache file on code model update Folder is not found in Test Explorer: /users/ganyu/git/dsda-doom/prboom2 {}

For reference, the workspace path is /users/ganyu/git/dsda-doom, and the top-level CMakeLists.txt is located in the subdirectory prboom2, and set through this workspace setting:

"cmake.sourceDirectory": "${workspaceFolder}/prboom2"

When this error happens, the CPU usage skyrockets, and no command from the status bar or the command palette have any effect.

It should be noted that this issue does not happen when then CMakeLists.txt is at the root of the directory.

CMake Tools Diagnostics

{
  "os": "darwin",
  "vscodeVersion": "1.77.3",
  "cmtVersion": "1.14.29",
  "configurations": [
    {
      "folder": "/Users/ganyu/git/dsda-doom",
      "cmakeVersion": "unknown",
      "configured": false,
      "generator": "unknown",
      "usesPresets": false,
      "compilers": {}
    }
  ],
  "cpptoolsIntegration": {
    "isReady": false,
    "hasCodeModel": false,
    "activeBuildType": "",
    "buildTypesSeen": [],
    "requests": [],
    "responses": [],
    "partialMatches": [],
    "targetCount": 0,
    "executablesCount": 0,
    "librariesCount": 0,
    "targets": []
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": null
    }
  ]
}

Debug Log

[main] Starting new CMake driver
[main] Starting CMake driver
[main] Using generator from user configuration: Ninja
[cmakefileapi-driver] Creating instance of CMakeFileApiDriver
[driver] Initializating base driver using kit
[kit] Testing Clang binary: /usr/bin/clang
[proc] Executing command: /usr/bin/clang -v
[kit] Detected Clang compiler: /usr/bin/clang
[driver] CMakeDriver Kit set to Clang 14.0.0 arm64-apple-darwin21.6.0
[kit] The environment for kit 'Clang 14.0.0 arm64-apple-darwin21.6.0': {
  "CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
  "CMAKE_GENERATOR": "Ninja",
  "COMMAND_MODE": "unix2003",
  "DISPLAY": "/private/tmp/com.apple.launchd.vhtLMmhK1P/org.xquartz:0",
  "EDITOR": "nvim",
  "ELECTRON_NO_ATTACH_CONSOLE": "1",
  "HOME": "/Users/ganyu",
  "HOMEBREW_CELLAR": "/opt/homebrew/Cellar",
  "HOMEBREW_PREFIX": "/opt/homebrew",
  "HOMEBREW_REPOSITORY": "/opt/homebrew",
  "INFOPATH": "/opt/homebrew/share/info:",
  "LANG": "en_GB.UTF-8",
  "LESSHISTFILE": "/Users/ganyu/.cache/less/history",
  "LESS_TERMCAP_mb": "\u001b[1;31m",
  "LESS_TERMCAP_md": "\u001b[1;36m",
  "LESS_TERMCAP_me": "\u001b[0m",
  "LESS_TERMCAP_se": "\u001b[0m",
  "LESS_TERMCAP_so": "\u001b[01;33m",
  "LESS_TERMCAP_ue": "\u001b[0m",
  "LESS_TERMCAP_us": "\u001b[1;32m",
  "LOGNAME": "ganyu",
  "MANPATH": "/opt/homebrew/share/man::",
  "MallocNanoZone": "0",
  "ORIGINAL_XDG_CURRENT_DESKTOP": "undefined",
  "PAGER": "less",
  "PATH": "/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/opt/devkitpro/tools/bin:/Library/Apple/usr/bin:/Applications/Wireshark.app/Contents/MacOS:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin",
  "PWD": "/Users/ganyu",
  "SHELL": "/opt/homebrew/bin/zsh",
  "SHELL_SESSIONS_DISABLE": "1",
  "SHLVL": "2",
  "SSH_AUTH_SOCK": "/private/tmp/com.apple.launchd.ifgPJL8VDY/Listeners",
  "TERM": "xterm-256color",
  "TERM_PROGRAM": "Apple_Terminal",
  "TERM_PROGRAM_VERSION": "447",
  "TERM_SESSION_ID": "C5104603-BD80-41AB-A96D-FA2371358A74",
  "TMPDIR": "/var/folders/pm/wyy2q8sn3qj235t35_w1pgbm0000gn/T/",
  "USER": "ganyu",
  "VSCODE_AMD_ENTRYPOINT": "vs/workbench/api/node/extensionHostProcess",
  "VSCODE_CLI": "1",
  "VSCODE_CODE_CACHE_PATH": "/Users/ganyu/Library/Application Support/Code/CachedData/704ed70d4fd1c6bd6342c436f1ede30d1cff4710",
  "VSCODE_CRASH_REPORTER_PROCESS_TYPE": "extensionHost",
  "VSCODE_CWD": "/Users/ganyu",
  "VSCODE_HANDLES_UNCAUGHT_ERRORS": "true",
  "VSCODE_IPC_HOOK": "/Users/ganyu/Library/Application Support/Code/1.77-main.sock",
  "VSCODE_NLS_CONFIG": "{\"locale\":\"en\",\"osLocale\":\"en-gb\",\"availableLanguages\":{},\"_languagePackSupport\":true}",
  "VSCODE_PID": "6659",
  "XPC_FLAGS": "0x0",
  "XPC_SERVICE_NAME": "application.com.microsoft.VSCode.62244229.62244235.2454D30D-8EA9-4344-A2EA-890CA5926AEB",
  "__CFBundleIdentifier": "com.microsoft.VSCode",
  "__CF_USER_TEXT_ENCODING": "0x1F5:0x0:0x2",
  "ELECTRON_RUN_AS_NODE": "1",
  "VSCODE_L10N_BUNDLE_LOCATION": ""
}
[driver] Setting new variant RelWithDebInfo
[rollbar] Unhandled exception: Failed to open CMake cache file on code model update Folder is not found in Test Explorer: /users/ganyu/git/dsda-doom/prboom2 {}

Additional Information

Here is a sample project to reproduce the issue:

toplevel/
|- subdir/
| |- CMakeLists.txt

Content of toplevel/.vscode/settings.json:

{
  "cmake.sourceDirectory": "/path/to/toplevel/subdir"
}

Content of toplevel/subdir/CMakeLists.txt:

cmake_minimum_required(VERSION 3.0)
project(repro)

message("Hello world")

Metadata

Metadata

Assignees

No one assigned

    Labels

    buga bug in the productregressionused to work and no longer does. Regressions are typically high priority

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions