microsoft / vscode-cmake-tools

CMake integration in Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=vector-of-bool.cmake-tools
MIT License
1.48k stars 453 forks source link

cmake tools kits scan when update a kit in the same path it won't update the json file correctly #4143

Closed Raffaello closed 3 weeks ago

Raffaello commented 4 weeks ago

Brief Issue Summary

for e.g. installing GCC 13.2 with mingw

using it with VS code (running scan for kits)

then upgrading to GCC 14.2

running again scan for kits.

the result is there are 2 kits pointing at the same path. The latter is correct.

So the error is scan for kits function doesn't update/replace (or simply remove older entries) when a new kit is discovered that has the same path of something that is already present in the list (or in the cmake-tools-kits.json file).

detailed e.g. with cmake-tools-kits.json

{
    "name": "GCC 13.2.0 x86_64-w64-mingw32 (ucrt64)",
    "compilers": {
      "C": "C:\\msys64\\ucrt64\\bin\\gcc.exe",
      "CXX": "C:\\msys64\\ucrt64\\bin\\g++.exe"
    },
    "isTrusted": true,
    "environmentVariables": {
      "CMT_MINGW_PATH": "C:\\msys64\\ucrt64\\bin",
      "MSYSTEM": "UCRT64",
      "MSYSTEM_PREFIX": "/ucrt64",
      "PATH": "C:\\msys64\\ucrt64\\bin;C:\\msys64\\usr\\bin;${env:PATH}"
    },
    "preferredGenerator": {
      "name": "MinGW Makefiles"
    }
  },
  {
    "name": "GCC 14.2.0 x86_64-w64-mingw32 (ucrt64)",
    "compilers": {
      "C": "C:\\msys64\\ucrt64\\bin\\gcc.exe",
      "CXX": "C:\\msys64\\ucrt64\\bin\\g++.exe"
    },
    "isTrusted": true,
    "environmentVariables": {
      "CMT_MINGW_PATH": "C:\\msys64\\ucrt64\\bin",
      "MSYSTEM": "UCRT64",
      "MSYSTEM_PREFIX": "/ucrt64",
      "PATH": "C:\\msys64\\ucrt64\\bin;C:\\msys64\\usr\\bin;${env:PATH}"
    },
    "preferredGenerator": {
      "name": "MinGW Makefiles"
    }
  }

as you can see it is obliviously an error having the same compilers PATH but 2 different kits

NOTE: in this specific case even the PATH is the same.

CMake Tools Diagnostics

No response

Debug Log

No response

Additional Information

this is an error on the internal data design, it should something unique, like the full path of the compiler exe. Understand it might be tricky when there are multiple compilers, but for sure when all the compilers are matching another kit, it can be considered a duplicate, like the example above.

Furthermore it could even do a 2nd level comparison on the enviromentalVariable if also those 2 are the same.. ... well the only thing change most likely is only the name. 

in this specific e.g. should have just update the kit's name as the final result.

Amy-Li03 commented 3 weeks ago

Thank you for reporting issue here. I believe it is a duplicate of https://github.com/microsoft/vscode-cmake-tools/issues/2570. If you can go add a 👍 reaction to that issue, that helps us rank issues by priority. If there is something else to this issue that that one does not cover, please let us know.