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 430 forks source link

Unhandled exception: Unhandled Promise rejection #570

Closed RolfNoot closed 2 years ago

RolfNoot commented 5 years ago

Brief Issue Summary

  1. Unhandled exception: Unhandled Promise rejection
  2. Unable to determine what CMake generator to use

    Expected:

Build or Clean

CMake Tools Log

2018-10-27T21:04:43.254Z [debug] [extension] [1906] cmake.clean started
2018-10-27T21:04:43.255Z [debug] [main] Run build clean
2018-10-27T21:04:43.291Z [debug] [main] Starting new CMake driver
2018-10-27T21:04:43.291Z [debug] [main] Starting CMake driver
2018-10-27T21:04:43.291Z [debug] [driver] CMakeDriver Kit set to GCC for arm-none-eabi 7.3.1
2018-10-27T21:04:43.291Z [debug] [driver] Run _refreshExpansions
2018-10-27T21:04:43.291Z [debug] [cms-driver] Run doRefreshExpansions
2018-10-27T21:04:43.291Z [debug] [driver] Run _refreshExpansions cb
2018-10-27T21:04:43.306Z [debug] [cms-client] Started new CMake Server instance with PID 8120
2018-10-27T21:04:44.313Z [debug] [driver] Trying to detect generator supported by system
2018-10-27T21:04:44.441Z [debug] [main] Starting new CMake driver
2018-10-27T21:04:44.442Z [debug] [main] Starting CMake driver
2018-10-27T21:04:44.442Z [debug] [driver] CMakeDriver Kit set to GCC for arm-none-eabi 7.3.1
2018-10-27T21:04:44.442Z [debug] [driver] Run _refreshExpansions
2018-10-27T21:04:44.443Z [debug] [cms-driver] Run doRefreshExpansions
2018-10-27T21:04:44.443Z [debug] [driver] Run _refreshExpansions cb
2018-10-27T21:04:44.449Z [debug] [cms-client] Started new CMake Server instance with PID 10012
2018-10-27T21:04:45.469Z [debug] [driver] Trying to detect generator supported by system
2018-10-27T21:04:45.533Z [fatal] [rollbar] Unhandled exception: Unhandled Promise rejection: clean Error: Impossible: CMake driver died immediately after successful configure {}
2018-10-27T21:13:44.407Z [debug] [extension] [9692] cmake.cleanRebuild started
2018-10-27T21:13:44.407Z [debug] [main] Run build clean
2018-10-27T21:13:44.455Z [debug] [main] Starting new CMake driver
2018-10-27T21:13:44.455Z [debug] [main] Starting CMake driver
2018-10-27T21:13:44.455Z [debug] [driver] CMakeDriver Kit set to GCC for arm-none-eabi 7.3.1
2018-10-27T21:13:44.456Z [debug] [driver] Run _refreshExpansions
2018-10-27T21:13:44.456Z [debug] [cms-driver] Run doRefreshExpansions
2018-10-27T21:13:44.456Z [debug] [driver] Run _refreshExpansions cb
2018-10-27T21:13:44.463Z [debug] [cms-client] Started new CMake Server instance with PID 9240
2018-10-27T21:13:45.467Z [debug] [driver] Trying to detect generator supported by system
2018-10-27T21:13:45.612Z [debug] [main] Starting new CMake driver
2018-10-27T21:13:45.612Z [debug] [main] Starting CMake driver
2018-10-27T21:13:45.612Z [debug] [driver] CMakeDriver Kit set to GCC for arm-none-eabi 7.3.1
2018-10-27T21:13:45.613Z [debug] [driver] Run _refreshExpansions
2018-10-27T21:13:45.613Z [debug] [cms-driver] Run doRefreshExpansions
2018-10-27T21:13:45.613Z [debug] [driver] Run _refreshExpansions cb
2018-10-27T21:13:45.619Z [debug] [cms-client] Started new CMake Server instance with PID 7944
2018-10-27T21:13:46.626Z [debug] [driver] Trying to detect generator supported by system
2018-10-27T21:13:46.693Z [fatal] [rollbar] Unhandled exception: Unhandled Promise rejection: cleanRebuild Error: Impossible: CMake driver died immediately after successful configure {}

Platform and Versions

vector-of-bool commented 5 years ago

CMake version 0.0.17 seems very suspect. Where did you get that version number?

RolfNoot commented 5 years ago

Oops sorry, cmake version 3.12.3 Updated to 1.1.3 and still the same problem.

RolfNoot commented 5 years ago

Just created a blank project. Trying to do "install", still got the same cryptic message: [rollbar] Unhandled exception: Unhandled Promise rejection: build Error: Impossible: CMake driver died immediately after successful configure {}

Why is it so hard to show a decent error message??? Like a file/folder is missing.

I don't have any clue right now. Mingw is installed, GCC installed, cMake installed. System paths are correct, Folder references are correct... HELP!!!

RolfNoot commented 5 years ago

After some tests, funny things seems to happen: 1) Close VS Code 2) delete CMake build folder contents 3) Start VS Code 4) CMake > Configure: Unable to determine what CMake generator to use. Please install or configure a preferred generator, or update settings.json or your Kit configuration. 5) Command line: cmake -DCMAKE_TOOLCHAIN_FILE="cmake/arm-none-eabi-toolchain.cmake" .. -G "MinGW Makefiles" .. 6) CMake > Configure: OK 7) delete CMake build folder contents 8) CMake > Configure: OK

RolfNoot commented 5 years ago

Any support whatsoever???

KoeMai commented 5 years ago

I think the prefered generator in the kit inside of the user kit file is not set. How does your kit file looks like?

RolfNoot commented 5 years ago

This is the kit file:

[
  {
    "name": "GCC",
    "compilers": {
      "C": "C:/ModusToolbox_1.0/tools/gcc-7.2.1-1.0/bin/arm-none-eabi-gcc.exe",
      "CXX": "C:/ModusToolbox_1.0/tools/gcc-7.2.1-1.0/bin/arm-none-eabi-g++.exe"
    }
  },
  {
    "name": "GCC for arm-none-eabi 7.3.1",
    "compilers": {
      "C": "C:\\Program Files (x86)\\GNU Tools Arm Embedded\\7 2018-q2-update\\bin\\arm-none-eabi-gcc.exe",
      "CXX": "C:\\Program Files (x86)\\GNU Tools Arm Embedded\\7 2018-q2-update\\bin\\arm-none-eabi-g++.exe"
    }
  }
]

This is in settings:

 "cmake.preferredGenerators": [
        "MinGW Makefiles",
        "Ninja",
        "Unix Makefiles"
    ]

And finally found out that adding: "cmake.generator": "MinGW Makefiles" solved the problem. Which makes no sense at all as the preferredGenerator is already set...

KoeMai commented 5 years ago

I tried to trace your problem. It seems that the extension does not found a matching build tool for the generators, by using "cmake. Generator" you force the generator. The debugging Information inside of the generator matching function (getBestGenerator(..)) are Not that detailed. But it looks like that it does not found "mingw32-make" or it has a bad return Code or it crashs (dll missing) . Could you try to add the prefered generator and the mingw path to your kit in the kitfile


{ "name": arm "GCC 7.3.1",
  "compilers": { 
     "C": "[...]",
     "CXX": "[...] "
   },
  "preferredGenerator": { "name": "MinGW Makefiles" },
  "environmentVariables": { "PATH": "${env:PATH};C:\\msys64\\usr\\bin" }
 }```
RolfNoot commented 5 years ago

That doesn't work! Unhandled Promise rejection: cleanConfigure Error {} Testing from command line shows PATH is added:

C:\Users\rolf>mingw32-make
mingw32-make: *** No targets specified and no makefile found.  Stop.
  {
    "name": "GCC for arm-none-eabi 7.3.1",
    "compilers": {
      "C": "C:\\Program Files (x86)\\GNU Tools Arm Embedded\\7 2018-q2-update\\bin\\arm-none-eabi-gcc.exe",
      "CXX": "C:\\Program Files (x86)\\GNU Tools Arm Embedded\\7 2018-q2-update\\bin\\arm-none-eabi-g++.exe"
    },
    "preferredGenerator": { "name": "MinGW Makefiles" }
  }

Forcing the generator is the only option to get it working as it seems right now.

A request would be to get a more informative error / debug log though...

KoeMai commented 5 years ago

Was the mingw32-make result from the vscode terminal?

Do you still get the same Unhandled Promise rejection error? Unhandled exception: Unhandled Promise rejection: cleanRebuild Error: Impossible: CMake driver died immediately after successful configure {}

RolfNoot commented 5 years ago

It was from an external dos command prompt. I tried to do: "environmentVariables": { "PATH": "${env:PATH};C:\\MinGW\\bin" } but this destroyed my path variable (compiler couldn't be found anymore).

I noticed differences in the path from vscode integrated terminal and the external dos prompt so I did a fresh Windows restart.

Finally your suggestion adding"preferredGenerator": { "name": "MinGW Makefiles" } in the kits file worked out well and I'm able to remove the generator forcing from the settings.

KoeMai commented 5 years ago

You are right, substitution of ${env:PATH} inside a kit is not supported. If you use environmentVariables then you need to add all build and kit needed paths to the kit environmentVariables.

RolfNoot commented 5 years ago

Okay, thanks! Problem solved!

rcdailey commented 5 years ago

I'm still getting this failure @vector-of-bool. I tried the solutions mentioned here but nothing works.

MBetters commented 4 years ago

I'm getting it too. I had to delete my build folder, close VS Code completely, reopen the project, and do a clean, clean reconfigure, and clean rebuild to get it to work.

ThinAirSystems commented 3 years ago

Im getting this error now too. Been through the numerous threads on this error and no luck so far. Can I just point the CMake Path directly to the executable? If so, where is it?

Im using only the CMake extension in VS Code. I do not have CMake itself installed. This was working fine upon initial setup but broke shortly after.

Thanks in advance for the help

andreeis commented 3 years ago

The CMake Tools extension does not install the CMake binary. I hope I am not missing something, but I always download one from https://cmake.org/download and install it manually. I assumed everyone did the same. I am puzzled about you saying this ever worked for you, without installing CMake yourself. What is your environment? Windows, WSL, MINGW/MSYS, Linux, Mac?

andreeis commented 3 years ago

@Eight9inerEcho, the problem you have, even if it's similar, it is highly unlikely to be related to this old report, so I opened a new one here: https://github.com/microsoft/vscode-cmake-tools/issues/1722. Let's continue our investigation over there.

ThinAirSystems commented 3 years ago

Environment is windows. After this post I was doing more digging and realized that cmake was in fact installed as part of a toolchain install I had done previously. Presumably, the installer created a new PATH variable which is why VS code found it.

So now I know what directory to find the cmake executable in, but even when pointing VS code explicitly to that location, I get the same error.

andreeis commented 3 years ago

What's the output of "cmake --version"? Increase your logging verbosity with "cmake.loggingLevel": "Debug" in your .vscode/settings.json, reload your project and share with us the text in the "CMake/Build" output channel. Does the same happen when you create a new small project (for example, with the quick start command in the palette)?

ThinAirSystems commented 3 years ago

Cmake version is 3.14.5

here's the output from CMake/Build

[main] Building folder: PX4-Autopilot [rollbar] Unhandled exception: Unhandled Promise rejection: build Error: Build failed: Unable to configure the project {}

Same result when using the Cmake quickstart

andreeis commented 3 years ago

Can you share the output also from a configure command, not just a build command? It should be longer than that. And did you set verbosityLevel to debug? Then can you upgrade your cmake to latest and see if this solves the problem? To not lose track of a potential bug, I will downgrade cmake on a system over here (to the 3.14 that you mention) just to double check if the extension fails to address something when cmake is that old.

ThinAirSystems commented 3 years ago

The configuration happens automatically when I select a build kit (not an expert on how this works so apologies for my ignorance here)

[main] Safe constructing new CMakeTools instance [variant] Constructing VariantManager [main] Constructing new CMakeTools instance [main] Starting CMakeTools second-phase init [variant] Loaded new set of variants [main] CMakeTools instance initialization complete. [kit] Reading kits file C:\Users\armer\AppData\Local\CMakeTools\cmake-tools-kits.json [kit] Successfully loaded 0 kits from C:\Users\armer\AppData\Local\CMakeTools\cmake-tools-kits.json [kit] Reading kits file c:\PX4\home\PX4-Autopilot.vscode\cmake-kits.json [kit] Successfully loaded 1 kits from c:\PX4\home\PX4-Autopilot.vscode\cmake-kits.json [main] Injecting new Kit into CMake driver [extension] Configuring workspace on open file:///c%3A/PX4/home/PX4-Autopilot [main] Configuring folder: PX4-Autopilot [main] Saving open files before configure/build [extension] [3892] cmake.buildType started [extension] [3892] cmake.buildType finished (returned "RelWithDebInfo") [extension] [1797] cmake.buildDirectory started [main] Starting new CMake driver [main] Starting CMake driver [cmakefileapi-driver] Creating instance of CMakeFileApiDriver [driver] CMakeDriver Kit set to PX4 detect [driver] Trying to detect generator supported by system [driver] Command version test return code -1 [driver] Command version test return code -1 [driver] Command version test return code -1 [driver] Run _refreshExpansions [driver] Run _refreshExpansions cb [main] Unable to determine what CMake generator to use. Please install or configure a preferred generator, or update settings.json, your Kit configuration or PATH variable. Error: No usable generator found. [main] Starting new CMake driver [main] Starting CMake driver [cmakefileapi-driver] Creating instance of CMakeFileApiDriver [driver] CMakeDriver Kit set to PX4 detect [driver] Trying to detect generator supported by system [driver] Command version test return code -1 [driver] Command version test return code -1 [driver] Command version test return code -1 [driver] Run _refreshExpansions [driver] Run _refreshExpansions cb [main] Unable to determine what CMake generator to use. Please install or configure a preferred generator, or update settings.json, your Kit configuration or PATH variable. Error: No usable generator found. [extension] [1797] cmake.buildDirectory finished (returned null) [main] Starting new CMake driver [main] Starting CMake driver [cmakefileapi-driver] Creating instance of CMakeFileApiDriver [driver] CMakeDriver Kit set to PX4 detect [driver] Trying to detect generator supported by system [driver] Command version test return code -1 [driver] Command version test return code -1 [driver] Command version test return code -1 [driver] Run _refreshExpansions [driver] Run _refreshExpansions cb [main] Unable to determine what CMake generator to use. Please install or configure a preferred generator, or update settings.json, your Kit configuration or PATH variable. Error: No usable generator found.

The toolchain install instructions for this project specifically say that not to upgrade Cmake. Not sure why but I try real hard to RTFM so I intentionally did not upgrade.

below is a screenshot showing an attempted build with the same issue

image

ThinAirSystems commented 3 years ago

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?

andreeis commented 3 years ago

Try to use the available settings that influence the generator decision: "cmake.generator" or "cmake.preferredGenerator" or preferred generator in your kit definition. If none is specified, the extension tries to select one from a list of defaults and for windows what it usually looks for is "Ninja". Do you have ninja installed on your windows?

More info about CMake generators: https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html.

github-actions[bot] commented 2 years ago

This issue has been closed automatically because it needs more information and has not had recent activity.