Unable to start debugging : The value of miDebuggerPath is invalid
Asked Answered
S

8

48

I recently started working on vscode. I wanted to debug my C code. But the moment I am launching the debugger getting Error : Unable to start debugging. The value of miDebuggerPath is invalid.

I have my gdb installed on wsl . It's path is /usr/bin/gdb. I have copied same path to launch.json in miDebuggerPath.

Here is my launch.json :

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [


    {
        "name": "(gdb) Launch",
        "type": "cppdbg",
        "request": "launch",
        "program": "${workspaceFolder}/bin/main",
        "args": [],
        "stopAtEntry": false,
        "cwd": "${workspaceFolder}",
        "environment": [],
        "externalConsole": true,
        "MIMode": "gdb",
        "miDebuggerPath": "/usr/bin/gdb",
        "setupCommands": [
            {
                "description": "Enable pretty-printing for gdb",
                "text": "-enable-pretty-printing",
                "ignoreFailures": true
            }
        ]
    }
]

}

It should not throw the error and I should able to launch my debugger.

Sincere answered 28/5, 2019 at 14:12 Comment(3)
Is VSCode launched in WSL or in Windows?Katy
Ever got it working?Kohn
code.visualstudio.com/docs/cpp/config-mingw Missing the mingw-w64-gdb package is one cause of the "The value of miDebuggerPath is invalid." message upon attempted compilation if your PATH is correct.Richards
P
81

So this happened to me on WSL-Ubuntu. In my case gdb was broken because of unmet dependencies. Took a while to fix but once I reinstalled gdb properly in my WSL-Ubuntu, I finally got it working.

Installing gdb can be done on shell as

sudo apt-get install gdb

There can be multiple reasons why it could end up as broken, but once you fix gdb, vscode-debugging should be running. At the very least, you won't see that error popping.

Potentiometer answered 22/3, 2020 at 14:43 Comment(2)
For Arch-based Linux users: sudo pacman -S gdb archlinux.org/packages/extra/x86_64/gdbPelecypod
This answer worked for me. I had a new WSL installation, so before trying the suggested command, my gdb was in /usr/share/gdb and even when I put this path in my lauch.json, it still did not work. When I installed gdb as per the suggested command, everything worked as expected (and gdb was installed in /usr/bin/gdb)Waites
S
9

I had the same problem, my solution was:

1. Change this section in launch.json

"miDebuggerPath": "/usr/bin/gdb",

for:

"miDebuggerPath": "C:/MinGW/bin/gdb.exe",

2. Do you need to install in your PC MinGW, this is the link:

https://osdn.net/projects/mingw/downloads/68260/mingw-get-setup.exe/

3. Next, open the MinGW then you install in the URL "C:/MinGW/bin" the gdb (select)

mingw32-gdb-bin

4. Enjoy the vs-code

Sonasonant answered 29/5, 2020 at 4:33 Comment(3)
The description is actually saying it's under wsl, not mingwGelya
IT worked for me just by changing to C:/MinGW/bin/gdb.exe. TyForeignborn
I'm not sure if this is the best way to do it, since you are referencing a file stored on your Windows system from the linux subsystem. Ideally, those two remain as separate as possible.Meyers
C
3

it should be

"miDebuggerPath": "/usr/bin/gdbus",
Ciera answered 27/1, 2020 at 21:35 Comment(1)
Why? gdbus doesn't appear to have anything to do with gdb. Also, I get the error Unknown command '--interpreter=mi'Essence
J
3

If you're running under WSL, you should check where gdb is in your current distro to set your "miDebuggerPath" using

whereis gdb

in my case it was in

/usr/bin/gdb

but it could be somewhere else, that depends on what Linux distribution are you using with WSL

Jestude answered 23/6, 2020 at 11:32 Comment(0)
L
1

I had the similar problem, running on linux. Installing gdb fixed it.

Liederkranz answered 6/11, 2022 at 7:57 Comment(0)
U
0

Could you try this:

sudo apt install binfmt-support

I am using VcXsrv, and this fixed all my installation problems, including chrome and GNU C++.

Underdeveloped answered 18/10, 2020 at 4:43 Comment(0)
P
0

i had a similar problem ,this fixed. WINDOWS 10

QUICK ANSWER : try 1)C:\your compiler\bin\gdb.exe (paste your compiler path ) or 2)C:\TDM-GCC-32\bin\gdb32.exe for 32 bit compiler .(in my case)

(i tried to use opengl GLFW glad with 32bit tdm-gcc c++ compiler , i used a repo from OpenGL C++ template by vkphillia

but when i tried to run it in vs code using "run without debugging " option ,it showed the error "Unable to start debugging : The value of miDebuggerPath is invalid",

i copied my tdm_gcc compiler's bin path in midebugger path and it was like this , C:\TDM-GCC-32\bin\gdb.exe , but it did not remove the error then i checked for the gdb.exe application in my tdm gcc compiler bin where i noticed that there was no gdb.exe but a gdb32.exe file

Pintsize answered 4/2, 2021 at 6:57 Comment(0)
N
0

You may be running your workspace under Windows environment while the actual compilation and debugging environment was originally from/for another platform (ex: Ubuntu).

I faced the same situation described in the question. I created my git repo under Windows, opened VSCode in Windows then added the folder to my workspace. I have a separate Ubuntu WSL shell opened on the side doing all the compiling just fine, but it doesn't work when I debug it.

The solution for me was:

  • close and discard my workspace (because it was under Windows environment)
  • use Remote Explorer and connect to my Ubuntu WSL container first
  • add my folder back into the new workspace (now under Ubuntu)
  • recreate the debug profile and everything worked just fine

You don't even need to change the miDebuggerPath.

"miDebuggerPath": "/usr/bin/gdb",
Nictitate answered 16/7, 2024 at 23:29 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.