Search code examples
c++visual-studio-codewindows-subsystem-for-linux

Visual Studio Code - C/C++ Extension commands don't exist


I've been using WSL2 with the C/C++ Extension on Visual Studio Code for quite a while now, but recently, it stopped working. Whenever I try to run a command, such as Edit Configurations, this error pops up:

error message (see below for text version)

Text version:

Command 'C/C++: Edit Configurations (UI)' resulted in an error (command 'C_Cpp.ConfigurationEditUI' not found)

Note that this happens for every command from that extension, and other commands work perfectly fine (including from other extensions). My IntelliSense has also stopped working properly (nothing appears when I click CTRL+SPACE, etc).

I tried reinstalling the extension multiple times, including going to previous versions, deleting the folder, restarting my computer, etc., but nothing ever helped. There seem to be no errors in the console either.

This happened right after I installed the PROS Extension for VSCode which happens to have a dependency for clangd, which I believe is the problem (I'm on Windows Subsystem for Linux, meaning the extension is installed on Ubuntu, and I use the GNU GCC/G++ compiler). Does anyone know how I can fix this? (I don't want to reinstall Visual Studio Code or do anything drastic as I have a lot of extensions with lots of configurations that would be lost if I do so).


Solution

  • This is an issue because clangd and intellisense do not work together. If you disabled intellisense in favor of clangd then the c/c++ configuration json/ui commands will not work. Instead of the configuration for the c/c++ extension you must generate a compile_commands.json for clangd using CMAKE. The fix that worked for me in order to revert back to the c/c++ configuration was to completely uninstall vscode and re-intall a clean version (attempted to uninstall all extensions). Though, I'm sure there is a solution that does not require a clean install.

    Edit: fix avoiding clean install :

    • uninstall clangd from the extensions

    • Go to File->Preferences->Parameters

    • In the search box at the top, type "Intellisense engine"

    • Look for C_Cpp: IntelliSense Engine and set the value to "Default"

    the setting

    side note: In my opinion, Clangd is faster than intellisense at syntax highlighting which was the main incentive for me to install clangd in the first place. So if that is ever an issue for you it may be worth diving in.