dbg not working on VScode with WSL2 - Unable to resolve non-existing file 'vscode-remote://wsl+ubuntu-20.04..'

Viewed 2848

I've installed WSL2 and build tool and everything is working well on linux console (including a test c++ program I was able to debug with dbg). I'm now trying to have a working development environment on my windows10 machine, by installing VSCode and a couple of extensions (c/c++ and Remote WSL).

Build works just fine, but when I try to debug, after executing (F10) a couple of lines I get the error:

Unable to open 'libc-start.c': Unable to read file 'vscode-remote://wsl+ubuntu-20.04/build/glibc-YYA7BZ/glibc-2.31/csu/libc-start.c' (Error: Unable to resolve non-existing file 'vscode-remote://wsl+ubuntu-20.04/build/glibc-YYA7BZ/glibc-2.31/csu/libc-start.c').

From that point on debugger basically doesn't work anymore, every time I press F10 (or F11) I get a new popup with the same error

screenshot of error and dev environment

Pressing the "Create File" button results in an "Unable to write file 'vscode-remote://wsl+ubuntu-20.04...." (same file as above).

here following my launch.json file

    {
    // 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": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [],
            "stopAtEntry": true,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

and my tasks.json:

{
// See https://go.microsoft.com/fwlink/?LinkId=733558 
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
    {
        "type": "shell",
        "label": "C++ Compile",
        "command": "/usr/bin/g++",
        "args": ["-g","*.cpp","-o","${fileDirname}/${fileBasenameNoExtension}"],
        "options": {"cwd": "${workspaceFolder}"},
        "problemMatcher": ["$gcc"],
        "group": {"kind": "build","isDefault": true}
    }
]

}

I've searched quite a bit before posting. Other have had similar problems in older posts but most of them claimed that being an old bug and they say the problem was solved with the upgrade. I'm running latest version of everything I'm using (including VSCode and the plugins).

thank you in advance to anyone helping out.

1 Answers

Adding

"sourceFileMap": { "//wsl$/Ubuntu-20.04" : "/" }

to the launch.json resolved the problem for me.

Related