Are you wsl version 1 or 2? I am having the same problem with wsl 1 as you. I solved this problem by upgrading wsl to wsl 2.

To see whether your Linux distribution is set to WSL 1 or WSL 2, use the command: wsl -l -v. To change versions, use the command: wsl --set-version <distro name> 2 replacing with the name of the Linux distribution that you want to update. For example, wsl --set-version Ubuntu-20.04 2 will set your Ubuntu 20.04 distribution to use WSL 2.

If an error occurs during the upgrade process, refer to Microsoft's official documentation. Here's the link

Answer from wzhlin on Stack Overflow
Top answer
1 of 3
5

The issue seem to be, that clion can't find the cmake, C compiler, or C++ compiler of the WSL. My guess is that you haven't installed those yet.

You can install gcc with:

sudo apt install build-essential

This article explains how to build cmake:

Go to — https://cmake.org/files/ That shows all the list of the versions of cmake, I use cmake-3.15.0-rc1.tar.gz.

Open your terminal or bash and download it.

wget https://cmake.org/files/v3.15/cmake-3.15.0-rc1.tar.gz

After downloading, then untar.

tar -xvzf cmake-3.15.0-rc1.tar.gz
cd cmake-3.15.0-rc1/
./bootstrap
sudo make
sudo make install
cd /bin/
sudo cp cmake /usr/bin/

Now don’t forget we are currently in cmake-3.15.0-rc1/ just go back by entering cd ... that takes you up one directory back. Now copy the directory to /usr/bin/share

sudo cp -r cmake-3.15.0-rc1/ /usr/share/cmake-3.15
export CMAKE_ROOT=/usr/share/cmake-3.15

After you have done that, clion should be able to detect everything correctly.

2 of 3
5

I faced a similar issue today and this is what worked for me:

  1. Upgrade your CLion IDE if possible.

    • On my CLion v2019.2.3, the IDE wasn't even able to detect that I had already installed 'wsl2 Ubuntu v22.04'. This was resolved by upgrading to CLion IDE v2023.1.3.
  2. In your 'wsl2 Ubuntu shell terminal', update the package index files on your system.

    • sudo apt update
  3. Install the 'build-essential' package in your 'wsl2 Ubuntu shell terminal. These will contain the GNU/g++ compiler collection and a couple more libraries and tools needed for compiling a program.

    • sudo apt install build-essential
  4. Install the 'cmake' package in your 'wsl2 Ubuntu shell terminal.

    • sudo apt install cmake
  5. Install the 'gdb' debugger for C (and C++) in your 'wsl2 Ubuntu shell terminal.

    • sudo apt install gdb
  6. Restart your IDE and reconfigure your 'Tool chain' to use WSL. All entries will now be auto-detected.

🌐
Tudelft3d
tudelft3d.github.io › geogeeks › cpp › wslclion
Windows: WSL & CLion - geogeeks
GDB is a debugger for C++ and you will need it in CLion to connect to WSL. If you are installing GDB right after CMake, you are probably still in the cmake-3.20.0 folder on your Ubuntu terminal. First, go back to the home directory: ... If this method does not work for you, you can also install ...
🌐
JetBrains
jetbrains.com › help › clion › configuring-debugger-options.html
Debugger options | CLion Documentation
February 25, 2026 - By default, commands from project-specific init files are not executed for security reasons. To allow that, modify the init file in your home directory as described below. Set permissions in the ~/.gdbinit file. With GDB 11.1 and newer, you can use $HOME/.config/gdb/gdbinit or $HOME/Library/Preferences/gdb/gdbinit instead. When working with WSL, edit the .gdbinit file located in WSL's home directory, /home/[user]/.gdbinit.
🌐
Medium
medium.com › shehuawwal › using-wsl-toolchains-in-jetbrains-clion-on-windows-90c9fd07af17
Using WSL Toolchains In Jetbrains CLion On Windows | by Shehu Awwal | Shehu Awwal | Medium
April 24, 2020 - We have already done most of the settings, Now Open Clion and go to file > settings > Build, Execution, Deployment, > Tools Chain Click On Settings Icon In Credential And Input The Credentials.
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 4408397282962-Ubuntu-WSL-is-listed-in-Clion-toolchains-but-says-not-found-
Ubuntu WSL is listed in Clion toolchains but says "not found" – IDEs Support (IntelliJ Platform) | JetBrains
October 19, 2021 - CLion seems to detect the WSL correctly. Also, when I install another WSL (like Ubuntu 18.04), it is automatically added in the list. You can see that Ubuntu-20.04 is listed but still not found : ... Do you have compilers (gcc, g++), make, GDB and CMake installed in your Ubuntu WSL distribution (sudo apt install build-essential, sudo apt install gdb, sudo apt install cmake)?
🌐
JetBrains
youtrack.jetbrains.com › issue › CPP-35617 › Debugger-Not-Working-WSL-in-Clion
Debugger Not Working WSL in Clion : CPP-35617
{{ (>_<) }} This version of your browser is not supported. Try upgrading to the latest stable version. Something went seriously wrong
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 360003397620-CLion-Windows-WSL-Ubuntu-18-04-ssh-error-not-finding-cmake-g-gdb
CLion Windows WSL Ubuntu 18.04 ssh error, not finding cmake, g++, gdb – IDEs Support (IntelliJ Platform) | JetBrains
March 27, 2019 - Hi Anna! I had tried following the recommendation from the error message but the error persists (sorry I should have mentioned that in my original post). After following the recommendation the CLion settings screen still returns empty credentials and can't found cmake, gcc/g++ and gdb.
Find elsewhere
🌐
JetBrains
jetbrains.com › help › clion › quick-tutorial-on-configuring-clion-on-windows.html
Tutorial: Configure CLion on Windows | CLion Documentation
April 8, 2026 - Bundled GDB is recommended, since it is guaranteed to include Python support required for CLion data renderers. GDB does not yet support debugging on Windows ARM64.
🌐
JetBrains
jetbrains.com › help › clion › how-to-use-wsl-development-environment-in-product.html
WSL2 | CLion Documentation
1 month ago - The list includes the distributions detected by wsl.exe --list, which includes the imported ones. If CLion cannot find your WSL executable, the reason might be the WSL issue fixed in Windows 10 version 1803.
🌐
JetBrains
youtrack.jetbrains.com › issue › CPP-42270 › CLion-generates-an-invalid-substitute-path-for-GDB-in-WSL
CLion generates an invalid substitute-path for GDB in WSL : CPP-42270
November 18, 2024 - GDB: Breakpoint is not hit during debug. Error in re-setting breakpoint 1: No source file ... In fact, for some reason, GDB invoked by CLion 2024.3 in WSL does not auto-load ~/.gdbinit anymore so there is no way of fixing the path substitution in CLion and debugging is permanently broken for WSL if objects are compiled with relative or dummy paths.
🌐
Stack Overflow
stackoverflow.com › questions › 61918924 › clion-wsl-debugger-version-not-supported
valgrind - CLion WSL Debugger Version Not Supported - Stack Overflow
May 20, 2020 - I've recently installed WSL (WSL 1, not WSL 2) on my Windows 10 64-bit with Ubuntu 20.04 (latest LTS version) and CLion 2020.1.1 (latest version). Using WSL, my CLion can run and execute C programs normally but according to the Toolchains page, the Debugger version is not supported for some reason (picture attached).
🌐
JetBrains
youtrack.jetbrains.com › issue › CPP-14181
gdb "Not found, please install that package" but it is installed
{{ (>_<) }} This version of your browser is not supported. Try upgrading to the latest stable version. Something went seriously wrong
🌐
JetBrains
youtrack.jetbrains.com › issue › CPP-11903 › WSL-Improve-error-message-when-gdb-isnt-installed
Improve error message when gdb isn't installed : CPP-11903
{{ (>_<) }} This version of your browser is not supported. Try upgrading to the latest stable version. Something went seriously wrong
🌐
University of Washington
faculty.washington.edu › pisan › misc › clion.html
Setting up your Development Environment
Follow instructions on https://www.jetbrains.com/help/clion/how-to-use-wsl-development-environment-in-clion.html and https://blog.jetbrains.com/clion/2018/01/clion-and-linux-toolchain-on-windows-are-now-friends/ to setup ubuntu-clion connection · sudo apt-get install cmake gcc clang gdb build-essential ·
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 4408324275730-CLion-WSL-Path-Configuration
CLion-WSL Path Configuration – IDEs Support (IntelliJ Platform) | JetBrains
October 17, 2021 - At the end it turned out that applying the file wasn't a problem at all, it was just CLion which uses hardcoded /usr/bin/cmake. The same applies to gdb path. ... Rakjak2 you can specify the paths to CMake and GDB in `File | Settings | Build, Execution, Deployment | Toolchains`. ... Yes, with specifying the paths manually it works, I thought that it will find it in the PATH variable when I choose "WSL CMake", but apparently CLion doesn't run detection command with -l option to load .profile file in this case.
🌐
GitHub
github.com › elmot › clion-embedded-arm › issues › 122
Improve WSL support · Issue #122 · elmot/clion-embedded- ...
September 24, 2018 - Host machine is windows but the build happen on ubuntu (WSL). Debugger should use windows path to .elf file. Instead uses WSL path to .elf file. Expected Behavior Debugger is running on windows hos...
Author   elmot
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 360000181099-Windows-10-x64-Can-t-configure-Clion-with-Windows-Subsystem-for-Linux
Windows 10 x64: Can't configure Clion with Windows Subsystem for Linux – IDEs Support (IntelliJ Platform) | JetBrains
September 7, 2018 - When I setup credentials to "ssh://user@localhost:2222" I can see the error: "Credentials are not valid for this WSL distribution (Ubuntu 18.04)". ... Same problem here... ... Hello! What CLion version do you use? The issue should be fixed in CLion 2018.1.5 and CLion 2018.2. EAP. ... I'm using CLion 2018.1.5 but the error is still existing. /usr/bin/cmake, /usr/bin/make, /usr/bin/cc, /usr/bin/c++ and WSL GDB (\usr\bin\gdb) detected successfully but I can see the error: "Credentials are not valid for this WSL distribution (Ubuntu 18.04)".