Open erikgrahn13 opened 11 months ago
@erikgrahn13 My intuition is that it's editing the PATH, but the VS Code environment itself isn't being changed. I've marked this as a bug and put in on our backlog.
Thanks!
I ran into the same issue with an other setup, but the cause is the same: the evaluation of the cmake executable path is performed without/before the evaluation of the Kits environmentSetupScript
.
My workaround is maybe a bit less ugly and works for all projects on the same host without a volatile, user specific absolute path in the sources:
Create a /usr/local/bin/cmake
for all users on the host or a user specific one without root: ~/.local/bin/cmake
with the following content:
#!/bin/sh
if test "$(which cmake)" = "$0"; then
# Don't call ouselves
exec /usr/bin/cmake "$@"
fi
exec cmake "$@"
and make it executable. It is in the default PATH before /usr/bin
and will be executed instead of the /usr/bin/cmake
The thing is that I run this inside a devcontainer where all my colleagues uses the same image and we are not root user. The container has conan package manager installed that fetches cmake as a "tool requirement". So the conan environment is "installed" after the devcontainer and cmake tools extension is started/initialized. Since all my colleagues uses the same devcontainer, the hard coded path to the cmake executable is not the worst problem. The issue is that you need to "reload window" in VSCode everytime you rebuild the devcontainer to have the environmentSetupScript initiliazed with the conan environment
Brief Issue Summary
I am using a devcontainer that has cmake version 3.16 installed in the base image. I am using Conan to fetch my dependencies and also fetch a newer version of cmake (3.26). Conan installs that in its default path and handles everyhting.
When conan has installed all its dependencies it gives me a conanbuild.sh script to source so that all my env variables and paths are set according to how conan has set everything up. When running
$ source conanbuild.sh
In the terminal and i later typecmake --version
It gives med 3.26I tried to add conanbuild.sh as the environmentSetupScript in the cmake-kits.json file. I have also added cmake.loggingLevel: debug in the settings.json so that it outputs a lot more logs. I get this in my output when selecting my cmake kit.
According to the logs it seems that the script was executed successfully and modified the PATH variable to include the path to where conan has installed cmake verison 3.26.
When I try to configure cmake with cmake-tools it still gives me this error:
CMake 3.20.0 or higher is required. You are running version 3.16.3
If I source conanbuild.sh manually in the terminal and manually configure cmake in the terminal it succeeds cause cmake version is 3.26. But vscode still has the old version of 3.16 when trying to configure using cmake-tools, even though the logs from the cmake-kit states that everything was OK. I have tried restarting and reloading vscode several times but nothing works
I am expecting that my cmake configuration is based on the cmake-kit i have selected and all environment configuration that script is doing.
My ugly work around at the moment is that I have manually modified the cmakePath in settings.json
"cmake.cmakePath": "/home/builder/.conan2/p/cmake5aa963403baef/p/bin/cmake"
CMake Tools Diagnostics
No response
Debug Log
No response
Additional Information
No response