Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake Tools 1.13.40 fails to pick up CMakeUserPresets.json (only on first start after updating?) #2952

Closed
floooh opened this issue Jan 20, 2023 · 9 comments · Fixed by #2966
Assignees
Labels
bug a bug in the product Feature: activation related to extension activation
Milestone

Comments

@floooh
Copy link

floooh commented Jan 20, 2023

Brief Issue Summary

After updating to 1.13.40, CMake Tools fails to pick up my CMakeUserPresets.json file, CMake: Build does nothing no build or debug target is selected, and selecting one is not possible, in short: nothing works :)

This happened to me both on macOS and Windows (so now the second time on Windows I'm writing this ticket).

...ok, weird: after setting the logging output to debug as requested below, and restarting, it suddenly worked.

AHA: starting another time it doesn't work again, really weird.

Then starting again, it picks up the configuration and now it seems like it's consistently working. Very confusing.

CMake Tools Diagnostics

{
  "os": "win32",
  "vscodeVersion": "1.74.3",
  "cmtVersion": "1.13.40",
  "configurations": [
    {
      "folder": "e:\\projects\\sokol-samples",
      "cmakeVersion": "3.25.1",
      "configured": false,
      "generator": "Visual Studio 17",
      "usesPresets": true,
      "compilers": {}
    },
    {
      "folder": "e:\\projects\\fips-imgui-dock",
      "cmakeVersion": "unknown",
      "configured": false,
      "generator": "unknown",
      "usesPresets": false,
      "compilers": {}
    },
    {
      "folder": "e:\\projects\\sokol",
      "cmakeVersion": "3.25.1",
      "configured": false,
      "generator": "",
      "usesPresets": true,
      "compilers": {}
    }
  ],
  "cpptoolsIntegration": {
    "isReady": true,
    "hasCodeModel": false,
    "activeBuildType": "",
    "buildTypesSeen": [],
    "requests": [
      "file:///e%3A/projects/sokol/tests/compile/sokol_gfx.c",
      "file:///e%3A/projects/sokol/tests/compile/sokol_gfx.cc",
      "file:///e%3A/projects/sokol/sokol_gfx.h"
    ],
    "responses": [],
    "partialMatches": [],
    "targetCount": 0,
    "executablesCount": 0,
    "librariesCount": 0,
    "targets": []
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": false
    },
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": null
    },
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": false
    }
  ]
}

Debug Log

[main] Safe constructing new CMakeProject instance
[variant] Constructing VariantManager
[main] Constructing new CMakeProject instance
[main] Starting CMake Tools second-phase init
[variant] Loaded new set of variants
[kit] Reading kits file C:\Users\floh\AppData\Local\CMakeTools\cmake-tools-kits.json
[kit] Successfully loaded 12 kits from C:\Users\floh\AppData\Local\CMakeTools\cmake-tools-kits.json
[kit] Not reading non-existent kits file: e:\projects\sokol-samples\.vscode\cmake-kits.json
[presetController] Reading presets file E:\projects\sokol-samples\CMakeUserPresets.json
[presetController] Successfully validated presets in E:\projects\sokol-samples\CMakeUserPresets.json
[main] Resolving the selected configure preset
[main] Loading new configure preset into CMake driver
[main] Resolving the selected build preset
[main] Using generator from user configuration: Ninja
[main] Loading new build preset into CMake driver
[main] CMakeProject instance initialization complete.
[proc] Executing command: C:\Users\floh\scoop\shims\cmake.EXE --version
[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 preset
[driver] CMakeDriver configure preset set to default
[driver] CMakeDriver build preset set to default
[cache] Reading CMake cache file E:/projects/fips-build/sokol-samples/sapp-d3d11-win64-vscode-debug/CMakeCache.txt
[cache] Parsing CMake cache string
[driver] Setting new variant Debug
[main] Safe constructing new CMakeProject instance
[variant] Constructing VariantManager
[main] Constructing new CMakeProject instance
[main] Starting CMake Tools second-phase init
[variant] Loaded new set of variants
[kit] Not reading non-existent kits file: e:\projects\fips-imgui-dock\.vscode\cmake-kits.json
[main] CMakeProject instance initialization complete.
[main] Not starting CMake driver: no kit selected
[main] Safe constructing new CMakeProject instance
[variant] Constructing VariantManager
[main] Constructing new CMakeProject instance
[main] Starting CMake Tools second-phase init
[variant] Loaded new set of variants
[kit] Not reading non-existent kits file: e:\projects\sokol\.vscode\cmake-kits.json
[presetController] Reading presets file E:\projects\sokol\tests\CMakePresets.json
[presetController] Successfully validated presets in E:\projects\sokol\tests\CMakePresets.json
[main] CMakeProject instance initialization complete.
[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 preset
[driver] Setting new variant Debug
[extension] Attempting to use cache to configure workspace file:///e%3A/projects/fips-imgui-dock
[main] Not starting CMake driver: no kit selected
[main] Unable to configure with existing cache
[extension] Attempting to use cache to configure workspace file:///e%3A/projects/sokol
[extension] Attempting to use cache to configure workspace file:///e%3A/projects/sokol-samples
[main] Unable to configure with existing cache
[main] Unable to configure with existing cache
[cache] Reading CMake cache file E:/projects/fips-build/sokol-samples/sapp-d3d11-win64-vscode-debug/CMakeCache.txt
[cache] Parsing CMake cache string
[extension] [4033] cmake.selectBuildPreset started
[extension] [4033] cmake.selectBuildPreset finished (returned false)
[extension] [5561] cmake.selectBuildPreset started
[extension] [5561] cmake.selectBuildPreset finished (returned false)
[extension] [2661] cmake.launchTarget started
[rollbar] Invalid folder. {}
[rollbar] No active CMake project. {}
[extension] [2661] cmake.launchTarget finished (returned -2)

After pressing F7 for build:

[rollbar] Invalid folder. {}
[rollbar] No active CMake project. {}
[extension] [1164] cmake.build finished (returned -2)

Additional Information

This is the CMakeUserPresets.json file:

{
  "version": 3,
  "cmakeMinimumRequired": {
    "major": 3,
    "minor": 21,
    "patch": 0
  },
  "configurePresets": [
    {
      "name": "default",
      "displayName": "sapp-d3d11-win64-vscode-debug",
      "binaryDir": "E:/projects/fips-build/sokol-samples/sapp-d3d11-win64-vscode-debug",
      "generator": "Visual Studio 17",
      "architecture": "x64",
      "cacheVariables": {
        "CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
        "CMAKE_BUILD_TYPE": "Debug",
        "FIPS_CONFIG": "sapp-d3d11-win64-vscode-debug",
        "FIPS_LOCAL_BUILD": "OFF",
        "USE_SOKOL_APP": {
          "type": "BOOL",
          "value": "ON"
        },
        "SOKOL_USE_D3D12": {
          "type": "BOOL",
          "value": "ON"
        },
        "FIPS_AUTO_IMPORT": "OFF"
      }
    }
  ],
  "buildPresets": [
    {
      "name": "default",
      "configurePreset": "default",
      "configuration": "Debug"
    },
    {
      "name": "debug",
      "configurePreset": "default",
      "configuration": "Debug"
    },
    {
      "name": "release",
      "configurePreset": "default",
      "configuration": "Release"
    }
  ]
}
@dbenson2000
Copy link

I hit the same issue and after struggling to get things working googled to find out how to install a previous version.
I had "cmake.useCMakePresets": "never" set but it still failed to find CMake settings.

@elahehrashedi
Copy link
Contributor

@dbenson2000 we are investigating this issue, meanwhile, can you try reloading the window or running "CMake: Delete cache and reconfigure" to see if it works or not?

@elahehrashedi elahehrashedi added the bug a bug in the product label Jan 20, 2023
@vdilecce
Copy link

I experienced more or less the same problems with 1.13.40.

I tried running command CMake: Reset CMake Tools Extension State: it seemed to restore some sensible behavior, though since then the CMake Project Outline in the Activity Bar has gone completely empty (!?)

@elahehrashedi
Copy link
Contributor

@vdilecce Can you please provide some more explanation on 1) the error message you see, 2) and the steps you took before seeing the error, 3) and also share the "Cmake: log diagnostics"? That will help us repro the issue.
I am not able to repro the issue with the steps mentioned by @floooh.

@elahehrashedi elahehrashedi added the more info needed More info is needed from the community for us to properly triage and investigate. label Jan 20, 2023
@bobbrow
Copy link
Member

bobbrow commented Jan 20, 2023

I tried to repro with the CMakeUserPresets.json you shared and a multi-root folder like the Log above showed, but was unable to hit the problem. Based on the settings, it looked like 2 folders had cmake projects in them and one didn't. The logs indicate that no project is active. I'm not sure how the extension is getting into this state yet.

Possible workaround:
Click the little folder icon in the status bar
image
or run the "CMake: Select Active Folder" command to pick a folder/project to be the active one.

If this successfully works around it, let us know. And also let us know if there is text already in the statusbar that indicates one of the folders should have already been "active".

@bobbrow
Copy link
Member

bobbrow commented Jan 20, 2023

Actually, I think I have a repro. It involves reloading the window when a file which is not in any of the workspace folders is focused. Focusing any file from one of the workspace folders or using the other workarounds from my previous comment does address this problem.

@bobbrow bobbrow added IMPORTANT Feature: activation related to extension activation and removed more info needed More info is needed from the community for us to properly triage and investigate. labels Jan 20, 2023
@bobbrow bobbrow added this to the On Deck milestone Jan 20, 2023
@floooh
Copy link
Author

floooh commented Jan 21, 2023

@bobbrow I'm not 100% sure (since I couldn't reliably reproduce the issue anyway once it worked), but explicitely selecting the subproject might work. I had actually hidden this button in the status bar (because it was getting a bit too busy), otherwise I would probably had figured out that this was the issue hmm...

...maybe that's also a sign that CMake Tools shouldn't clutter the status bar like that ;) For instance maybe it makes sense to unify the build and debug target? It's kinda awkward that those are selected separately. Different topic though ;)

@kelteseth
Copy link

kelteseth commented Jan 21, 2023

Can confirm selecting my presets is gone since the last update...

@bobbrow
Copy link
Member

bobbrow commented Jan 23, 2023

@bobbrow I'm not 100% sure (since I couldn't reliably reproduce the issue anyway once it worked), but explicitely selecting the subproject might work. I had actually hidden this button in the status bar (because it was getting a bit too busy), otherwise I would probably had figured out that this was the issue hmm...

...maybe that's also a sign that CMake Tools shouldn't clutter the status bar like that ;) For instance maybe it makes sense to unify the build and debug target? It's kinda awkward that those are selected separately. Different topic though ;)

We are working on #1582 for 1.14 which will remove the buttons from the status bar

@github-actions github-actions bot locked and limited conversation to collaborators Mar 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.