microsoft / vscode-cmake-tools

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

[rollbar] Unhandled exception: Unhandled Promise rejection: build TypeError: Cannot read property '0' of undefined {} #608

Closed narutojxl closed 4 years ago

narutojxl commented 5 years ago

when i build a cpp project in VS Code, it print

[rollbar] Unhandled exception: Unhandled Promise rejection: build TypeError: Cannot read property '0' of undefined {}

My VS Code version="1.29.1", ubuntu 14.04, when type cmake --version, its output is "cmake version 3.12.3" , g++ --version ="g++ (Ubuntu 4.8.4-2ubuntu1~14.04.4) 4.8.4". I also install some VS Code extension, C/C++ 0.20.1, CMake 0.0.17, CMake Tools 1.1.3. BTW, when i installed ubuntu14.04.5, there is a cmake has been install in /usr/bin/cmake /usr/lib/cmake /usr/bin/X11/cmake /usr/share/cmake, all cmakes installed by myself are all installed as default in /usr/local/.

CMakeLists.txt is as follows:

cmake_minimum_required(VERSION 2.8.3) project(svd_p3p) add_compile_options(-std=c++11) find_package(catkin REQUIRED COMPONENTS roscpp ) find_package(Eigen3 REQUIRED) catkin_package( INCLUDE_DIRS include

LIBRARIES svd_p3p

CATKIN_DEPENDS roscpp

DEPENDS system_lib

) include_directories( include ${catkin_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIR} ) add_library( svd_p3p src/svd_p3p.cpp ) add_executable(localization_error src/localization_error.cpp) target_link_libraries(localization_error svd_p3p ${catkin_LIBRARIES}
)

when i uninstall cmake 3.12.3, type cmake --version, its output is cmake version 2.8.12.2. Reload VS Code, its output is [main] CMake Server is not available with the current CMake executable. Please upgrade to CMake 3.7.1 or newer. [rollbar] Unhandled exception: Unhandled Promise rejection: build TypeError: Cannot read property '0' of undefined {}

Again i install cmake 3.7.1, type cmake --version, output cmake version 3.7.1, but reload VS Code and rebuild project, it didn't find cmake 3.7.1, its output is the same as shown above.

Again i uninstall cmake 3.7.1, install cmake 3.7.2 , reload VS Code, its output is [rollbar] Unhandled exception: Unhandled Promise rejection: build Error: connect ENOENT /tmp/cmake-server-0.6890532608944027 {}

Any help will be much appreciated, thanks in advance!

narutojxl commented 5 years ago

when i uninstall all cmakes installed by myself, then reload VS Code is OK, it can build successfully, but can not debug. When launch debug, its output is

[build] Starting build [proc] Executing command: /usr/bin/cmake --build /home/jxl/jxl_ws/src/svd_p3p/build --config Debug --target all -- -j 6 [build] [1/4 25% :: 0.000] Building CXX object CMakeFiles/svd_p3p.dir/src/svd_p3p.cpp.o [build] [2/4 50% :: 7.713] Linking CXX shared library devel/lib/libsvd_p3p.so [build] [3/4 75% :: 8.063] Building CXX object CMakeFiles/localization_error.dir/src/localization_error.cpp.o [build] [4/4 100% :: 8.862] Linking CXX executable devel/lib/svd_p3p/localization_error [build] Build finished with exit code 0 [main] ======================================================= [main] No executable target was found to launch. Please check: [main] - Have you called add_executable() in your CMake project? [main] - Have you executed a successful CMake configure? [main] No program will be executed

According to Target Debugging and Launching in CMake Tools,

Debugging is only supported when using CMake Server mode. This mode will be enabled automatically on CMake versions at least as new as 3.7.2, but is completely unavailable on older CMake versions.

I am a ROS users, when i try to remove cmake 2.8.12.2 installed by ubuntu 14.04 or ROS-indigo(I am not sure which installed this cmake), it reminds me it will also remove many ROS bags, which i do not want. So without removing the native cmake installed by ubuntu or ROS, how to installed cmake >3.7.2, and then let VS Code's CMake extension tool to use this cmake, so i can debug project with VS Code.

TheErk commented 5 years ago

I guess you could simply install a newer cmake version in an alternative path

/usr/local/cmake-3.13/etc...

you can get pre-compiled version here: https://cmake.org/download/

In vscode configuration you should be able to point cmake.cmakePath to the right cmake. Or you may change your PATH variable (in your .bashrc) in order to put /usr/local/cmake-3.13/bin before /usr/bin/ so that "which cmake" shows the version of cmake you want to use. If you relaunch vscode in the modified environment it'll probably pickup the appropriate cmake version.

When you change CMake version you shall remove previously configured build directory which contains the old reference to /usr/bin/cmake

narutojxl commented 5 years ago

@TheErk , thank you for your attention. I have installed cmake 3.7.2 in /home/jxl/CMake-3.7.2/INSTALL_JXL/, and add this path export PATH=/home/jxl/CMake-3.7.2/INSTALL_JXL/bin/cmake:$PATH, and set vscode cmake.cmakePath=/home/jxl/CMake-3.7.2/INSTALL_JXL/bin/cmake, remove previously configured build directory, rebuild project failed, it output the same previously error.

[rollbar] Unhandled exception: Unhandled Promise rejection: build Error: connect ENOENT /tmp/cmake-server-0.5035176552028626 {}

In /tmp/ there is no cmake-server-* file and directory as follows:

jxl@lenovo:/tmp$ ls 138e719b-5fa5-4c2d-8853-2491d0212cb9 ef6ccda8-e41d-4134-84c8-74df807ac52c 15b69002-6d20-49db-ad80-c5abcc05e102 fcitx-socket-:0 2442a77c-6794-4a53-8a76-95a5728cbee9 FoxitReaderlite 27942acc-32fb-4a0c-bdb8-1c0e6f34c038 ibus.log 7351398b-a999-4987-8bc5-3a1b77c84dba orbit-jxl 8720a472-ba0e-4112-857a-fbeb66d64338 qtsingleapp-FoxitR-7748-3e8-lockfile a6eb0079-fda2-412c-bd60-3021010a5795 snap.1000_notepadqq_oogudf ac76f6d8-441b-4787-84bd-7f521448d7fe systemd-generator.0M1GLa appInsights-node systemd-generator.GccurL appInsights-nodeAIF-444c3af9-8e69-4462-ab49-4191e6ad1916 systemd-generator.MGUPHN appInsights-nodeAIF-d9b70cd4-b9f9-4d70-929b-a071c400b217 systemd-generator.t6tSxZ bfabd641-6f23-416a-9013-67a703ab216c unity_support_test.0 c62833d1-5fe8-444a-be7a-6e3f5aa9544a VSCode Crashes config-err-QggAd3 YourName Crashes edb3887d-fdb7-4da1-93a7-8f287d42a3b0 jxl@lenovo:/tmp$

narutojxl commented 5 years ago

I tried to install cmake 3.13.1 to /home/jxl/cmake-3.13.1/INSTALL_JXL/ and modified vscode cmake.cmakePath=/home/jxl/cmake-3.13.1/INSTALL_JXL/bin/cmake and export PATH=/home/jxl/cmake-3.13.1/INSTALL_JXL/bin/cmake:$PATH, reload vscode . it output:

[cms-client] Configuring using the "Ninja" CMake generator [cms-client] Configuring using the "Ninja" CMake generator [cmake] The C compiler identification is GNU 4.8.4 [cmake] The CXX compiler identification is GNU 4.8.4 [cmake] Check for working C compiler: /usr/bin/gcc-4.8 [cmake] Check for working C compiler: /usr/bin/gcc-4.8 -- works [cmake] Detecting C compiler ABI info [cmake] Detecting C compiler ABI info - done [cmake] Detecting C compile features [cmake] Detecting C compile features - done [cmake] Check for working CXX compiler: /usr/bin/g++-4.8 [cmake] Check for working CXX compiler: /usr/bin/g++-4.8 -- works [cmake] Detecting CXX compiler ABI info [cmake] Detecting CXX compiler ABI info - done [cmake] Detecting CXX compile features [cmake] Detecting CXX compile features - done [cmake] Using CATKIN_DEVEL_PREFIX: /home/jxl/jxl_ws/src/svd_p3p/build/devel [cmake] Using CMAKE_PREFIX_PATH: /home/jxl/carto_ws/install_isolated;/home/jxl/jxl_ws/devel;/opt/ros/indigo [cmake] This workspace overlays: /home/jxl/carto_ws/install_isolated;/home/jxl/jxl_ws/devel;/opt/ros/indigo [cmake] Found PythonInterp: /usr/bin/python (found version "2.7.6") [cmake] Using PYTHON_EXECUTABLE: /usr/bin/python [cmake] Using Debian Python package layout [cmake] Using empy: /usr/bin/empy [cmake] Using CATKIN_ENABLE_TESTING: ON [cmake] Call enable_testing() [cmake] Using CATKIN_TEST_RESULTS_DIR: /home/jxl/jxl_ws/src/svd_p3p/build/test_results [cmake] Looking for pthread.h [cmake] Looking for pthread.h - found [cmake] Looking for pthread_create [cmake] Looking for pthread_create - not found [cmake] Looking for pthread_create in pthreads [cmake] Looking for pthread_create in pthreads - not found [cmake] Looking for pthread_create in pthread [cmake] Looking for pthread_create in pthread - found [cmake] Found Threads: TRUE
[cmake] Found gtest sources under '/usr/src/gtest': gtests will be built [cmake] Using Python nosetests: /usr/bin/nosetests-2.7 [cmake] catkin 0.6.19 [cmake] CMake Error at CMakeLists.txt:22 (find_package): [cmake] By not providing "FindEigen3.cmake" in CMAKE_MODULE_PATH this project has [cmake] asked CMake to find a package configuration file provided by "Eigen3", but [cmake] CMake did not find one. [cmake] [cmake] Could not find a package configuration file provided by "Eigen3" with any [cmake] of the following names: [cmake] [cmake] Eigen3Config.cmake [cmake] eigen3-config.cmake [cmake] [cmake] Add the installation prefix of "Eigen3" to CMAKE_PREFIX_PATH or set [cmake] "Eigen3_DIR" to a directory containing one of the above files. If "Eigen3" [cmake] provides a separate development package or SDK, be sure it has been [cmake] installed. [cmake] [cmake] [cmake] Configuring incomplete, errors occurred! [cmake] See also "/home/jxl/jxl_ws/src/svd_p3p/build/CMakeFiles/CMakeOutput.log". [cmake] See also "/home/jxl/jxl_ws/src/svd_p3p/build/CMakeFiles/CMakeError.log". [cms-driver] Error during CMake configure: [cmake-server] Configuration failed.

In CMakeLists.txts, i have find Eigen3, but the local cmake can not find it, missing something??

narutojxl commented 5 years ago

In /usr/share/cmake-2.8/Modules/ there is FindEigen3.cmake, but in our locally installed cmake ~/cmake-3.13.1/INSTALL_JXL/share/cmake-3.13/Modules/ there is no FindEigen3.cmake file, so jxl@lenovo:/usr/share/cmake-2.8/Modules$ sudo cp -r FindEigen3.cmake ~/cmake-3.13.1/INSTALL_JXL/share/cmake-3.13/Modules/, reload vscode, now it can build successfully, but can not debug, when launch debug(F5), there is Run CTest launch target is shown in the status bar to the right of the Debug button not as Selecting a Launch Target said, and output is

[cms-driver] Found no matching code model for the current build type. This shouldn't be possible [cms-driver] Found no matching code model for the current build type. This shouldn't be possible [cms-driver] Found no matching code model for the current build type. This shouldn't be possible [main] Failed to prepare executable target with name 'undefined'

launch.json is:

{ // 使用 IntelliSense 了解相关属性。 // 悬停以查看现有属性的描述。 // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "(gdb) Launch", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/devel/lib/svd_p3p/localization_error", //"program": "${command:cmake.launchTargetPath}", "args": [ "/home/jxl/jxl_ws/src/svd_p3p/build/devel/lib/svd_p3p/amcl_laser_track_transform.txt", "/home/jxl/jxl_ws/src/svd_p3p/build/devel/lib/svd_p3p/amcl_laser_track_sample_datas.txt" ], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [ { "name": "PATH", "value": "/home/jxl/cmake-3.13.1/INSTALL_JXL/bin/cmake:$PATH" }, ], "externalConsole": true, "MIMode": "gdb", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ] } ] }

andreeis commented 4 years ago

We fixed several similar issues since this was opened and also fileApi deprecates CMakeServer. It's recommended that you upgrade CMake Tools to latest (today that is 1.3.1) and CMake to latest or at least 3.15. Reopen if you still have problems.