Nidhi Khanna
Nidhi Khanna

Reputation: 559

Unable to start debugging : The value of miDebuggerPath is invalid

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.

Upvotes: 52

Views: 125680

Answers (8)

codenamezero
codenamezero

Reputation: 3079

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",

Upvotes: 0

Akshar
Akshar

Reputation: 78

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

Upvotes: 1

DR 2020
DR 2020

Reputation: 11

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

Upvotes: 0

user5498548
user5498548

Reputation:

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++.

Upvotes: 0

Eugenio Miró
Eugenio Miró

Reputation: 2428

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

Upvotes: 4

uribealdo
uribealdo

Reputation: 119

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

Upvotes: 10

AzuxirenLeadGuy
AzuxirenLeadGuy

Reputation: 2870

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.

Upvotes: 82

bikpo
bikpo

Reputation: 47

it should be

"miDebuggerPath": "/usr/bin/gdbus",

Upvotes: 3

Related Questions