I have just installed Ubuntu 19.10 and used the Software installer application to install Visual Studio Code and CMake 3.15. I cloned my repository from GitHub and whenever I try to call CMake configure in Visual Studio code I get an error message: Bad CMake executable /snap/bin/cmake. CMake seems to run fine in a terminal.
VS Code/CMake extension used to run just fine out-of-the-box in previous version of Ubuntu.
When I try to enter the path manually I get error messages like these:
[rollbar] Unhandled exception: Unhandled Promise rejection: configure TypeError: Cannot read property 'on' of undefined {}
[rollbar] Unhandled exception: Error during CMake upgrade TypeError: Cannot read property 'on' of undefined {"version":"3.13.2","linuxURL":"https://github.com/Kitware/CMake/releases/download/v3.13.2/cmake-3.13.2-Linux-x86_64.sh","windowsURL":"https://github.com/Kitware/CMake/releases/download/v3.13.2/cmake-3.13.2-win64-x64.msi"}
Actually /snap/bin/cmake is not an executable but a link if I recall correctly.
A link should be ok. In your case the extension is running /snap/bin/cmake --version and inspecting the output to check if the executable is ok. Can you run that command and let me know what it prints out in your terminal?
The "unhandled exception" error is unrelated to this and should be gone in 1.2.0 (unreleased).
Ubuntu Terminal:
~$ /snap/bin/cmake --version
cmake version 3.15.4CMake` suite maintained and supported by Kitware (kitware.com/cmake).
VSCode Terminal:
~/Projects/GitHub/GunBox/GunBox$ ~$ /snap/bin/cmake --version
~$: command not found
~/Projects/GitHub/GunBox/GunBox$ cmake version 3.15.4
CMake Error: The source directory "/home/hristo/Projects/GitHub/GunBox/GunBox/3.15.4" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.
/Projects/GitHub/GunBox/GunBox$
~/Projects/GitHub/GunBox/GunBox$ CMake suite maintained and supported by Kitware (kitware.com/cmake).
bash: syntax error near unexpected token `('
~/Projects/GitHub/GunBox/GunBox$
I removed the PC name
This command also appears to execute properly: /snap/bin/cmake -E server --experimental
@bobbrow Will version 1.2 be released soon?
Yes. Should be early next week. We're doing some final testing.
OK. Thanks! I'll wait to see how version 1.2 will behave as the currently released doesn't work for me neither on latest Ubuntu nor Windows with the latest MSVC, CMake, GCC, etc. All of which worked before.
It works when you use /snap/cmake/current/bin/cmake as CMake Path. All snap executables seem to be just symbolic links to /usr/bin/snap, and that seems to work fine when called from a terminal but apparently not from the CMake extension in VSCode ...
@hheld Thank you for the advice. I'll try that. I tried setting this manually before but maybe I didn't set the proper path.
There are two entries related to CMake Path. Which one is the correct one:
Cmake: Cmake Path
Name/path of the CMake executable to use
cmake
Cmake: Ctest Path
Path to CTest executable. If null, will be inference from cmake.cmakePath (recommended to leave null)
Cmake: Cmake Path
The path to CMake generator executable
@hheld Setting /snap/cmake/current/bin/cmake did the job!

Thank you!
I also have the twxs's extension (which I hope will be absorbed into CMake Tools) but I don't think that it is causing that duplication.
@bobbrow Maybe this issue's title should be changed and filed as a bug: "CMake Tools" don't work with symbolic links on Linux?
I don't think this issue has anything to do with symbolic links. I don't really know the mechanics of how snap apps work, but I guess something must transform a call to /snap/bin/cmake to something like snap run cmake -- and I guess this doesn't happen when called from the VSCode extension. The link simply points to /usr/bin/snap and this isn't cmake.
In regard to this: https://github.com/microsoft/vscode-cmake-tools/issues/685#issuecomment-557335459
I'm also experiencing this issue on Ubuntu:
I installed vscode/cmake from snap packages
$ cmake --version
cmake version 3.16.0-rc4
CMake suite maintained and supported by Kitware (kitware.com/cmake).But I got this error from the vscode extension:
Bad CMake executable "/snap/bin/cmake". Is it installed or settings contain the correct path (cmake.cmakePath)?
I checked my path
echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/binI checked my cmake
$ which cmake
/snap/bin/cmake
The story so far...
The snap/bin/cmake links points to the snap application.
/snap/bin$ ls -l
total 0
lrwxrwxrwx 1 root root 12 ное 1 13:02 ccmake -> cmake.ccmake
lrwxrwxrwx 1 root root 13 ное 1 13:02 cmake -> /usr/bin/snap
lrwxrwxrwx 1 root root 13 ное 1 13:02 cmake.ccmake -> /usr/bin/snap
lrwxrwxrwx 1 root root 13 ное 1 13:02 cmake.cmake-gui -> /usr/bin/snap
lrwxrwxrwx 1 root root 13 ное 1 13:02 cmake.cpack -> /usr/bin/snap
lrwxrwxrwx 1 root root 13 ное 1 13:02 cmake.ctest -> /usr/bin/snap
lrwxrwxrwx 1 root root 15 ное 1 13:02 cmake-gui -> cmake.cmake-gui
lrwxrwxrwx 1 root root 13 ное 17 08:34 code -> /usr/bin/snap
lrwxrwxrwx 1 root root 13 ное 17 08:34 code.url-handler -> /usr/bin/snap
lrwxrwxrwx 1 root root 11 ное 1 13:02 cpack -> cmake.cpack
lrwxrwxrwx 1 root root 11 ное 1 13:02 ctest -> cmake.ctest
lrwxrwxrwx 1 root root 13 ное 1 13:15 gimp -> /usr/bin/snap
lrwxrwxrwx 1 root root 13 ное 1 13:02 gnome-calculator -> /usr/bin/snap
lrwxrwxrwx 1 root root 13 ное 17 08:34 gnome-characters -> /usr/bin/snap
lrwxrwxrwx 1 root root 13 окт 19 09:45 gnome-logs -> /usr/bin/snap
lrwxrwxrwx 1 root root 13 ное 22 09:04 node -> /usr/bin/snap
lrwxrwxrwx 1 root root 13 ное 22 09:04 node.npm -> /usr/bin/snap
lrwxrwxrwx 1 root root 13 ное 22 09:04 node.npx -> /usr/bin/snap
lrwxrwxrwx 1 root root 13 ное 22 09:04 node.yarn -> /usr/bin/snap
lrwxrwxrwx 1 root root 13 ное 22 09:04 node.yarnpkg -> /usr/bin/snap
lrwxrwxrwx 1 root root 8 ное 22 09:04 npm -> node.npm
lrwxrwxrwx 1 root root 8 ное 22 09:04 npx -> node.npx
lrwxrwxrwx 1 root root 9 ное 22 09:04 yarn -> node.yarn
lrwxrwxrwx 1 root root 12 ное 22 09:04 yarnpkg -> node.yarnpkg
snap list can be used to check for an installed cmake package.
/snap/bin$ snap list
Name Version Rev Tracking Publisher Notes
cmake 3.15.5 148 stable crascit✓ classic
code 8795a988 20 stable vscode✓ classic
core 16-2.42.1 8039 stable canonical✓ core
core18 20191030 1265 stable canonical✓ base
gimp 2.10.12 227 stable snapcrafters -
gnome-3-28-1804 3.28.0-16-g27c9498.27c9498 110 stable/… canonical✓ -
gnome-calculator 3.34.1+git1.d34dc842 544 stable/… canonical✓ -
gnome-characters v3.32.1+git2.3367201 367 stable/… canonical✓ -
gnome-logs 3.34.0 81 stable/… canonical✓ -
gtk-common-themes 0.1-25-gcc83164 1353 stable/… canonical✓ -
gtk2-common-themes 0.1 5 stable canonical✓ -
node 13.2.0 2559 13 nodesource✓ classic
snap run cmake to execute the snap package.
/snap/bin$ snap run cmake
Usage
cmake [options] <path-to-source>
cmake [options] <path-to-existing-build>
cmake [options] -S <path-to-source> -B <path-to-build>
Specify a source directory to (re-)generate a build system for it in the
current working directory. Specify an existing build directory to
re-generate its build system.
Run 'cmake --help' for more information.
cmake.cmakePath
Cmake: Cmake Path
Name/path of the CMake executable to use.
/snap/cmake/current/bin/cmake
"cmake.cmakePath": "/snap/cmake/current/bin/cmake"Cmake: Cmake Path
The path to CMake generator executable
"cmake.cmakePath": "/snap/cmake/current/bin/cmake"
I wonder how did the extension decide to use the path /snap/bin/cmake as a cmake.cmakePath setting?
There are two entries related to CMake Path. Which one is the correct one:
Cmake: Cmake Path
Name/path of the CMake executable to use
cmake
Cmake: Ctest Path
Path to CTest executable. If null, will be inference from cmake.cmakePath (recommended to leave null)
Cmake: Cmake Path
The path to CMake generator executable@hheld Setting
/snap/cmake/current/bin/cmakedid the job!
Thank you!I also have the twxs's extension (which I hope will be absorbed into CMake Tools) but I don't think that it is causing that duplication.
This fixed for me
There are two entries related to CMake Path. Which one is the correct one:
Cmake: Cmake Path
Name/path of the CMake executable to use
cmake
Cmake: Ctest Path
Path to CTest executable. If null, will be inference from cmake.cmakePath (recommended to leave null)
Cmake: Cmake Path
The path to CMake generator executable@hheld Setting
/snap/cmake/current/bin/cmakedid the job!
Thank you!
I also have the twxs's extension (which I hope will be absorbed into CMake Tools) but I don't think that it is causing that duplication.This fixed for me
This also worked for me. Thank you much!
I don't think this issue has anything to do with symbolic links. I don't really know the mechanics of how snap apps work, but I guess something must transform a call to
/snap/bin/cmaketo something likesnap run cmake-- and I guess this doesn't happen when called from the VSCode extension. The link simply points to/usr/bin/snapand this isn't cmake.
@hheld snap uses argv[0] for transforming the call to the "real" cmake.
My best educated guess is some code in the VS plugin fully resolves the symlink and invoke it, so argv[0] is lost in this process
@hheld Setting
/snap/cmake/current/bin/cmakedid the job!
Thank you!
I also have the twxs's extension (which I hope will be absorbed into CMake Tools) but I don't think that it is causing that duplication.This fixed for me
This also worked for me. Thank you much!
This also works for me. Many thanks!
But it would be nice if this issue can really be fixed (i.e. /snap/bin/cmake should ideally be fine).
@TianyiShi2001 Yesterday I setup a new Linux development environment and it is still The Way. I had the intention to fix this but Microsoft stopped reviewing and merging new PRs for nearly a year and I also stopped using VSCode, so I lost the motivation. Now I am back to using it but I doubt that I'll have the time.
I think implementing this functionality would be relatively easy. Typescript is easy. It will require some refactoring how CMake is detected though. Why not try to do it yourself? That would be a fun little project.
Unfortunately even the simplest features require a lot of iterations and thus a lot of time.
Most helpful comment
It works when you use
/snap/cmake/current/bin/cmakeasCMake Path. All snap executables seem to be just symbolic links to/usr/bin/snap, and that seems to work fine when called from a terminal but apparently not from the CMake extension in VSCode ...