Vscode-cmake-tools: Bad CMake executable "C:\Program Files\CMake\bin\cmake.exe".

Created on 16 May 2019  路  35Comments  路  Source: microsoft/vscode-cmake-tools

Brief Issue Summary

I had been using the extension for several months with little issue. One day, it stopped working. I get this error:
Bad CMake executable "C:\Program Files\CMake\bin\cmake.exe". Is it installed or settings contain the correct path (cmake.cmakePath)?
That path is correct, and I can still run cmake from the command line using that absolute path, as well as by the command line finding it in my PATH.

Expected:

  1. Push Configure button
  2. Project is configured.

Apparent Behavior:

  1. Push Configure button
  2. Error pops up. (text given above).

CMake Tools Log

2019-05-16T00:08:57.844Z [debug] [rollbar] Updated Rollbar payload {"environment":"production","packageJSON":{"name":"cmake-tools","version":"1.1.3"},"client":{"code_version":"1.1.3"},"platform":"win32"}
2019-05-16T00:08:57.957Z [debug] [kit] Reading kits file C:\Users\joee\AppData\Local\CMakeTools\cmake-tools-kits.json
2019-05-16T00:08:57.957Z [debug] [kit] Not reading non-existent kits file: c:\Users\joee\dev\cmaketest\.vscode\cmake-kits.json
2019-05-16T00:08:57.994Z [info] [kit] Successfully loaded 12 kits from C:\Users\joee\AppData\Local\CMakeTools\cmake-tools-kits.json
2019-05-16T00:08:57.996Z [debug] [main] Safe constructing new CMakeTools instance
2019-05-16T00:08:57.996Z [debug] [variant] Constructing VariantManager
2019-05-16T00:08:57.998Z [debug] [main] Constructing new CMakeTools instance
2019-05-16T00:08:57.998Z [debug] [main] Starting CMakeTools second-phase init
2019-05-16T00:08:57.998Z [debug] [rollbar] Checking Rollbar permissions
2019-05-16T00:08:57.998Z [debug] [rollbar] Rollbar enabled?  true
2019-05-16T00:08:58.033Z [info] [variant] Loaded new set of variants
2019-05-16T00:08:58.034Z [debug] [main] CMakeTools instance initialization complete.
2019-05-16T00:08:58.036Z [debug] [kit] Reading kits file C:\Users\joee\AppData\Local\CMakeTools\cmake-tools-kits.json
2019-05-16T00:08:58.051Z [info] [kit] Successfully loaded 12 kits from C:\Users\joee\AppData\Local\CMakeTools\cmake-tools-kits.json
2019-05-16T00:08:58.063Z [debug] [kit] Not reading non-existent kits file: c:\Users\joee\dev\cmaketest\.vscode\cmake-kits.json
2019-05-16T00:08:58.739Z [error] [main] Failed to get version information for CMake during upgarde
2019-05-16T00:09:04.013Z [debug] [extension] [6342] cmake.configure started
2019-05-16T00:09:04.013Z [debug] [extension] Start selection of kits. Found 13 kits.
2019-05-16T00:09:04.013Z [debug] [extension] Opening kit selection QuickPick
2019-05-16T00:09:07.778Z [debug] [extension] User selected kit  {"label":"VisualStudio.14.0 - x86","description":"Using compilers for VisualStudio.14.0 (x86 architecture)","kit":{"name":"VisualStudio.14.0 - x86","visualStudio":"VisualStudio.14.0","visualStudioArchitecture":"x86","preferredGenerator":{"name":"Visual Studio 14 2015"}}}
2019-05-16T00:09:07.779Z [debug] [rollbar] Updated Rollbar payload {"kit":{"name":"VisualStudio.14.0 - x86","visualStudio":"VisualStudio.14.0","visualStudioArchitecture":"x86","preferredGenerator":{"name":"Visual Studio 14 2015"}}}
2019-05-16T00:09:07.779Z [debug] [main] Injecting new Kit into CMake driver
2019-05-16T00:09:07.781Z [debug] [main] Run configure  
2019-05-16T00:09:07.781Z [debug] [main] Saving open files before configure/build
2019-05-16T00:09:08.376Z [debug] [extension] [6342] cmake.configure finished (returned -1)
2019-05-16T00:09:38.911Z [debug] [extension] [9226] cmake.viewLog started
bug] [extension] [5962] cmake.viewLog started
2019-05-16T00:06:42.724Z [debug] [extension] [5962] cmake.viewLog finished (returned undefined)
2019-05-16T00:07:54.282Z [debug] [extension] [5563] cmake.configure started
2019-05-16T00:07:54.282Z [debug] [main] Run configure  
2019-05-16T00:07:54.282Z [debug] [main] Saving open files before configure/build
2019-05-16T00:07:54.894Z [debug] [extension] [5563] cmake.configure finished (returned -1)
2019-05-16T00:08:01.181Z [debug] [extension] [3999] cmake.configure started
2019-05-16T00:08:01.181Z [debug] [main] Run configure  
2019-05-16T00:08:01.182Z [debug] [main] Saving open files before configure/build
2019-05-16T00:08:01.769Z [debug] [extension] [3999] cmake.configure finished (returned -1)
2019-05-16T00:08:05.661Z [debug] [extension] [1908] cmake.configure started
2019-05-16T00:08:05.662Z [debug] [main] Run configure  
2019-05-16T00:08:05.662Z [debug] [main] Saving open files before configure/build
2019-05-16T00:08:06.260Z [debug] [extension] [1908] cmake.configure finished (returned -1)
2019-05-16T00:08:07.230Z [debug] [extension] [8321] cmake.configure started
2019-05-16T00:08:07.233Z [debug] [main] Run configure  
2019-05-16T00:08:07.233Z [debug] [main] Saving open files before configure/build
2019-05-16T00:08:07.790Z [debug] [extension] [8321] cmake.configure finished (returned -1)
2019-05-16T00:08:18.032Z [debug] [extension] [4776] cmake.viewLog started
2019-05-16T00:08:18.110Z [debug] [extension] [4776] cmake.viewLog finished (returned undefined)
2019-05-16T00:08:53.117Z [debug] [extension] [4252] cmake.resetState started
2019-05-16T00:08:53.118Z [debug] [extension] [4252] cmake.resetState finished (returned undefined)
2019-05-16T00:08:53.168Z [debug] [extension] Deactivate CMakeTools
e.setVariant finished (returned false)
2019-05-15T23:15:01.394Z [debug] [extension] [2983] cmake.setVariant started
2019-05-15T23:15:04.686Z [debug] [extension] [2983] cmake.setVariant finished (returned false)
2019-05-15T23:16:33.379Z [debug] [extension] [7517] cmake.setVariant started
2019-05-15T23:16:37.191Z [debug] [main] Active build variant changed
2019-05-15T23:16:37.194Z [debug] [main] Run configure  
2019-05-15T23:16:37.195Z [debug] [main] Saving open files before configure/build
2019-05-15T23:16:38.147Z [debug] [extension] [7517] cmake.setVariant finished (returned true)
2019-05-15T23:19:58.161Z [debug] [extension] [7558] cmake.configure started
2019-05-15T23:19:58.161Z [debug] [main] Run configure  
2019-05-15T23:19:58.162Z [debug] [main] Saving open files before configure/build
2019-05-15T23:19:58.795Z [debug] [extension] [7558] cmake.configure finished (returned -1)
2019-05-15T23:25:26.998Z [debug] [extension] [1615] cmake.configure started
2019-05-15T23:25:27.000Z [debug] [main] Run configure  
2019-05-15T23:25:27.000Z [debug] [main] Saving open files before configure/build
2019-05-15T23:25:27.638Z [debug] [extension] [1615] cmake.configure finished (returned -1)
2019-05-15T23:28:19.000Z [debug] [extension] [1460] cmake.clean started
2019-05-15T23:28:19.001Z [debug] [main] Run build clean
2019-05-15T23:28:19.637Z [fatal] [rollbar] Unhandled exception: Unhandled Promise rejection: clean Error: Impossible: CMake driver died immediately after successful configure {}
2019-05-15T23:29:42.344Z [debug] [extension] [6241] cmake.clean started
2019-05-15T23:29:42.345Z [debug] [main] Run build clean
2019-05-15T23:29:42.997Z [fatal] [rollbar] Unhandled exception: Unhandled Promise rejection: clean Error: Impossible: CMake driver died immediately after successful configure {}
2019-05-15T23:29:46.657Z [debug] [extension] [8631] cmake.build started
2019-05-15T23:29:46.658Z [debug] [main] Run build 
2019-05-15T23:29:47.276Z [fatal] [rollbar] Unhandled exception: Unhandled Promise rejection: build Error: Impossible: CMake driver died immediately after successful configure {}
2019-05-15T23:29:55.438Z [debug] [extension] [2746] cmake.configure started
2019-05-15T23:29:55.439Z [debug] [main] Run configure  

Platform and Versions

  • Operating System: Windows 10
  • CMake Version: 3.14.4
  • VSCode Version: 1.33.1
  • CMake Tools Extension Version: 1.1.3
  • Compiler/Toolchain: multiple.

Other Notes/Information

I uninstalled cmake, reinstalled the latest version.
I uninstalled VS code, reinstalled the latest version.
I may have had other Cmake extensions installed at some point, but they are all removed now.
I already tried resetting the extension just now. No effect.

configure help wanted more info needed

Most helpful comment

I installed cmake again like below.

$ chmod +x cmake-3.7.2-Linux-x86_64.sh $ sudo ./cmake-3.7.2-Linux-x86_64.sh $ sudo mv cmake-3.7.2-Linux-x86_64 /opt $ sudo ln -s /opt/cmake-3.7.2-Linux-x86_64/bin/* /usr/bin
After that, it seems that vscode recognize cmake and cmake-tools also recognize cmake.

All 35 comments

Hey, it looks like a broken cmake path, or wrong cmake executable or missing Flfiles to start cmake.

What happens if you call cmake -version from a terminal inside of vscode?

What does the cmake.cmakePath settings looks like?

It does look that way, doesn't it?

cmake -version from the vscode terminal works fine.

C:\Users\joee\dev>cmake --version
cmake version 3.14.4

CMake suite maintained and supported by Kitware (kitware.com/cmake).

cmake.cmakePath is the path to the file. If I use this from the command line or the vs code terminal, it finds cmake, no problem.

I have also tried resetting this settings to the default, which is just "cmake". That doesn't work either. I have done all this for user settings and workspace settings. No luck.

Bear in mind, this was working fine for months, and just started failing with this error one day. I don't recall changing any settings right before it happened.

Sorry, I can not reconstruct your problem. There are no debug information to detect the return code or output of cmake. Maybe you could debug, an give me more detail whats happens in cmake-executable.ts function getCMakeExecutableInformation.

Thanks. I'm going to try this soon -- hopefully next week.

I have also faced on same problem.

My environment is below.

Ubuntu 18.04 TLS
cmake 3.15.0 : /usr/local/cmake
vscode 1.37.0

And, my error log in vscode is below.

Bad CMake executable "". Is it installed or settings contain the correct path (cmake.cmakePath)?

I installed cmake again like below.

$ chmod +x cmake-3.7.2-Linux-x86_64.sh $ sudo ./cmake-3.7.2-Linux-x86_64.sh $ sudo mv cmake-3.7.2-Linux-x86_64 /opt $ sudo ln -s /opt/cmake-3.7.2-Linux-x86_64/bin/* /usr/bin
After that, it seems that vscode recognize cmake and cmake-tools also recognize cmake.

I installed cmake again like below.

$ sudo ./cmake-3.7.2-Linux-x86_64.sh
$ sudo mv cmake-3.7.2-Linux-x86_64 /opt
$ sudo ln -s /opt/cmake-3.7.2-Linux-x86_64/bin/* /usr/bin

After that, it seems that vscode recognize cmake and cmake-tools also recognize cmake.

It seems that my problem depends on vscode.
It seems that vscode doesn't recognize cmake which is not path to /usr/bin

@nackdai your environment says you put cmake in /usr/local not /usr/local/bin, is that correct? Is /usr/local in your $PATH? The extension only auto-detects cmake if it's in your $PATH.

Sorry, I miss-typed in my first comment.
I write my situation again.

1) I installed cmake as /usr/local/bin/cmake and set /usr/local/bin/ in my $PATH.
But, in that case, it seemed that cmake was not detected automatically.

2) I removed cmake from /usr/local/bin/cmake and installed cmake again like below

$ sudo ./cmake-3.7.2-Linux-x86_64.sh
$ sudo mv cmake-3.7.2-Linux-x86_64 /opt
$ sudo ln -s /opt/cmake-3.7.2-Linux-x86_64/bin/* /usr/bin

In that case, it seems that cmake is detected automatically.

What difference are there between 1. and 2.?

The extension uses which cmake to find the path to cmake. There should have been no difference between the locations if your $PATH includes /usr/local/bin

I installed cmake as /usr/local/bin/cmake and set /usr/local/bin/ in my $PATH.
But, in that case, it seemed that cmake was not detected automatically.

In above case, cmake tools ran after I set cmake path directly like below.

[Settings]->[Extensions]->[CMake Tools Configuration]->[CMake:Cmake Path]
/usr/local/bin/cmake

I finally got around to playing with this today. I started with a fresh install of windows 10 (I was required to upgrade), cmake, VS code, the plugin -- everything. I still got this error. I wondered if the plugin might not like a cmake path with spaces in it, since my path did. I tried uninstalling / reinstalling cmake in c:cmake, and the problem went away.
It appears that the plugin is not currently compatible with the default cmake install folder on Windows. It'd be nice if it could support spaces in that path.
I really do wonder how I'm the only one filing a defect about this if that is all it was.
I also wonder how I had it working before, and then it stopped suddenly. I don't recall moving my cmake installation. I would like to think that the plugin used to support spaces in the path, and then a bug was introduced that broke that, and my updating the extension on my PC introduced the problem for me. That does not seem likely, but that's all I've got.

The extension does work with a version of CMake that has spaces in the path, so I think there's some other variable causing the problem. Can you share your settings?

Sure. It's a fresh VS.code install. I haven't set very much. The difference between working and not was where cmake was installed.

{
    "cmake.sourceDirectory": "${workspaceRoot}/projects/projname",
    "cmake.buildDirectory": "${workspaceRoot}/projects/projname",
    "cmake.configureOnOpen": true
}

What do you get when you run cmake --version?

(For context, I'm trying to emulate the code path that you're going through. Something seems to have failed around this point where we are detecting your CMake version. Note that this code has changed a little bit in version 1.2.0 which is being released this week, but I am testing on 1.1.3 to try to figure out your issue.)

cmake version 3.16.0-rc2

That matches the version on the cmake install packages that I used for both "c:\program filescmake" and "c:cmake".

I did just notice that I used their .msi for the program files one, and the zip file for the c:cmake one, which works. There could be a difference there, but it seems unlikely.

If you're using a custom cmake path, I didn't see it in the settings you've shared. How are you specifying cmake.cmakePath? Are you using \\ for slashes in the json? e.g.: C:\\program files\\cmake\\bin\\cmake.exe

You're right. I'm not currently setting cmake.cmakePath. I played around with that quite a bit, using \\ and /. I could not get it to work before -- I generally saw the "Bad CMake executable" error.

Now that it is working, I see it log the following in the output:
[proc] Executing command: C:\\cmake\\cmake-3.16.0-rc2-win64-x64\\bin\\cmake.exe --build ...

On the settings page, I can leave it with the default Cmake Path, "cmake", and it works. I can also enter "c:cmakecmake-3.16.0-rc2-win64-x64\bincmake.exe", which appears in the json as "c:\\cmake\\cmake-3.16.0-rc2-win64-x64\\bin\\cmake.exe", and it works. If I introduce a typo, I start getting this error again. This seems correct, now.

However, I'm pretty sure I tried all of this before when cmake was in "c:\program filescmake", and I could not get it to work.

I do have cmake.exe in my path, and at one point I had to set 'CMAKE_ROOT`. But I don't think those help the plugin find the binary.

Are you not able to reproduce the problem with cmake installed under "c:\program files"?

Are you not able to reproduce the problem with cmake installed under "c:\program files"?

Correct, I cannot repro the problem with cmake installed under C:\Program Files. And the extension does not check CMAKE_ROOT when looking for the binary.

I tried re-installing from the msi to "C:\program filescmake\bincmake.exe". I can type that into the command line with quotes, and the shell finds and runs it fine. The extension does not find it.

If I point the extension at my "c:cmakecmake-3.16.0-rc2-win64-x64\bincmake.exe", it works. If I rename that folder (It's from the zip, not the msi) to "C:cmake goodcmake-3.16.0-rc2-win64-x64\bincmake.exe" the extension finds it. This rules out my theory of spaces being a problem.

That leaves the possibility of the .msi being "bogus" somehow. If I install the msi into c:cmake, the extension finds it.

If I copy the .zip contents to "C:\Program Filescmakebcmake-3.16.0-rc2-win64-x64\bincmake.exe" and point the extension at it, it finds it.

That seems to rule it down to something very special about "C:\Program Filescmake\bincmake.exe". After a fresh install of windows and cmake, I can't imagine what would be special about it.

It seems to be something very specific about "C:\Program Filescmake\bin."

I tried moving the zip contents to "C:\Program Filescmakecmake-3.16.0-rc2-win64-x64\bincmake.exe". It finds it. That's a little different than the "specific" broken path.

I take that same zip contents and put them in "C:\Program Filescmake\bincmake.exe", and the extension cannot find it.

I rename the "bin" folder "bina", as follows: "C:\Program Filescmake\binacmake.exe". The extension can find it.

Every test, I tried running the same path on the command line, and it worked, (just to double check for a typo)

This seems to imply that it doesn't matter if it's from the zip or the msi. All that matters is if it is installed to c:\Program Filescmake\bin. It won't find it there. Anywhere else, and it will find it. This is pretty absurd.

This is a fresh install of Windows 10. Before, I was seeing this (although I didn't test all these cases) on Windows 7. That is one specific "bug". I don't know what else I can try. That is all I have time for at the moment. At least I have a workaround.

What does your %PATH% look like? I wonder if there's a bad path in there messing you up.
Can you run set PATH in a CMD window?

@jeverton I have a similar issue in Ubuntu https://github.com/microsoft/vscode-cmake-tools/issues/838

Also at present I can't get the extension to work on Windows 10, VS2019 and the latest CMake 3.16 at all (it cannot find any MSVC/Clang toolkits), so I wait for the new 1.2 release to see if anything has been fixed.

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/bin

I checked my cmake

$ which cmake
/snap/bin/cmake

@hdf89shfdfs Regarding snaps, please, check: #838 . I have it on my TODO list but I am not quite sure how to approach it yet.

I also encountered this problem when using the Remote Development Extension. It does not work with the path set to be ${userHome}/.local/bin/cmake.

If it helps, I have the same problem on KDE Neon (Linux). I uninstalled Cmake tools, reinstalled, no luck,
From VS Code terminal:

$ cmake --version
cmake version 3.16.3
$ which cmake
/usr/bin/cmake

The error that pops up is:
Bad CMake executable "/home/foobar/Projects/git/MyProject/.dependencies/cmake-3.15.5/bin/cmake". Is it installed or settings contain the correct path (cmake.cmakePath)?

There is no .dependencies folder under MyProject, I double checked.

This is on a fresh machine, fresh install of VSCode, no customized settings, just installed the extension and tried to open an existing project.
@bobbrow Any updates on this issue? It's been a while since it was opened... Thanks!

CMakeTools extension version: 1.5.3

VS Code Info:

Version: 1.51.1
Commit: e5a624b788d92b8d34d1392e4c4d9789406efe8f
Date: 2020-11-10T23:31:29.624Z
Electron: 9.3.3
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Linux x64 5.4.0-53-generic snap

I'm sorry, we haven't been able to reproduce this problem.

I faced the same problem on windows. I fixed it by :

  1. removing cmake.cmakePath from the settings.json file
  2. resetting the extension (CTRL+SHIFT+P then "CMake: Reset CMake Tools Extension State (For troubleshooting)"
  3. checking that cmake is in my Path
  4. just putting "cmake" (without the brackets) in the extension settings GUI
    image

I faced the same problem on windows. I fixed it by :

  1. removing cmake.cmakePath from the settings.json file
  2. resetting the extension (CTRL+SHIFT+P then "CMake: Reset CMake Tools Extension State (For troubleshooting)"
  3. checking that cmake is in my Path
  4. just putting "cmake" (without the brackets) in the extension settings GUI
    image

Also on windows. Confirmed that cmake.cmakePath is gone and "cmake" is in the extension settings. Still not working. Was there anything else you had to do for this?

@Eight9inerEcho, do you have the same problem on a small project that you create from scratch, for example with the command "CMake: Quick Start" in the palette?
Can you increase the logging verbosity with "cmake:loggingLevel": "Debug", reload the project and share us the text in the "CMake/Build" output channel?

I do have the same issue.

Verbosity set to debug. Below is a screenshot of an attempted build

image

I really think this is a problem with VS code having the wrong path for the Cmake executable. How can I find out where the Cmake executable was installed by the toolchain so I can point to in manually?

About finding the exact cmake executable installed by the toolchain, I don't know how to do that other than searching on your system for all cmake and trying to guess which one. Maybe there is documentation about that particular toolchain or if you run it again may give some path indication.

I am still thinking of what else can happen here.

mark

Was this page helpful?
0 / 5 - 0 ratings