microsoft / vscode-cmake-tools

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

Installing cmake after launching VS Code results in claims of a cmake invalid location, forcing user to restart VS Code to proceed #3811

Closed oursland closed 1 week ago

oursland commented 3 weeks ago

Brief Issue Summary

In environments where the cmake path points to a file that does not yet exist, installing cmake does not correct the issue requiring restaring VS Code to proceed.

An example is in projects where build dependencies are maintained through a local package manager such as conda. When the project is loaded, the path to cmake for the project is invalid. After installing the build dependencies, the vscode-cmake-tools extension does not attempt to use the newly installed cmake.

What is expected is that when attempting to use cmake an error due to the absence of the cmake executable should present a UI, and when the cmake executable is installed it should use this. The current implementation performs this check once, presumably to prevent multiple UI notifications of the cmake path error.

It would be preferable to try to run the cmake program each time to account for the possibility of the program being installed, and upon failure only present the error notification UI on the first failure.

CMake Tools Diagnostics

No response

Debug Log

No response

Additional Information

No response

oursland commented 3 weeks ago

Related to https://github.com/microsoft/vscode-cmake-tools/issues/3570

v-frankwang commented 3 weeks ago

@oursland I'm very sorry that I can't reproduce the problem you mentioned, I uninstalled cmake installed on my machine and running cmake: configure command gives me an error, when I reinstalled cmake without restarting vscode and ran cmake: configure command directly the cmake project can be configured successfully, can you give me some suggestions?

Repro steps: not repor

oursland commented 2 weeks ago

Hi @v-frankwang:

The steps to reproduce this issue may be observed in the following video:

https://github.com/microsoft/vscode-cmake-tools/assets/622450/8be96fc0-b75c-4b09-9efd-aed8bb5d4f24

This is performed when using the FreeCAD repository with VSCode.

  1. Checkout FreeCAD: git clone https://github.com/FreeCAD/FreeCAD.git
  2. Open FreeCAD in VSCode.
  3. In a terminal, copy the contrib/.vscode/ directory to the repo root directory: cp -a contrib/.vscode/ .
  4. The CMakePresets.json define the location of the cmake executable as conda/cmake.sh, which specifies the cmake binary within the to-be-installed conda environment. An error will be presented because this environment does not exist.
  5. Run conda/setup-environment.sh to install the packages, including cmake.
  6. Configure the CMake Configure Preset for Conda Debug or Conda Release.
  7. Run CMake: Configure.
  8. The error will again be presented as it does not pick up the now working cmake binary.