简体   繁体   English

dbg 无法使用 WSL2 处理 VScode - 无法解析不存在的文件“vscode-remote://wsl+ubuntu-20.04..”

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

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).我已经安装了 WSL2 和构建工具,并且在 linux 控制台上一切正常(包括我能够使用 dbg 调试的测试 c++ 程序)。 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).我现在正试图通过安装 VSCode 和几个扩展(c/c++ 和远程 WSL)在我的 windows10 机器上建立一个工作开发环境。

Build works just fine, but when I try to debug, after executing (F10) a couple of lines I get the error:构建工作得很好,但是当我尝试调试时,在执行(F10)几行后我得到了错误:

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从那时起,调试器基本上不再工作了,每次按 F10(或 F11)时,我都会收到一个带有相同错误的新弹出窗口

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).按下“创建文件”按钮会导致“无法写入文件 'vscode-remote://wsl+ubuntu-20.04....”(与上述相同的文件)。

here following my launch.json file在我的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": "${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:和我的任务。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).我正在运行我正在使用的所有东西的最新版本(包括 VSCode 和插件)。

thank you in advance to anyone helping out.提前感谢任何提供帮助的人。

Adding添加

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

to the launch.json resolved the problem for me.到launch.json为我解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Visual Studio Code - 远程调试 Bazel C++ - 无法读取文件 'vscode-remote://dev- 文件 - Visual Studio Code - Remote Debugging Bazel C++ - Unable to read file 'vscode-remote://dev- file 在 VSCode、WSL 和 C++ 中构建多个文件 - Building multiples files in VSCode and WSL and C++ VSCode Run C/C++ File 尝试在 WSL 集成终端中运行编译后的程序,而不是 CMD - VSCode Run C/C++ File attempts to run the compiled program in WSL integrated terminal instead of CMD 无法从 WSL2 启动 exe 文件 - Can't launch exe file from WSL2 标识符“NULL”未定义,标识符“strncpy”在wsl上的vscode中未定义 - identifier "NULL" is undefined and identifier "strncpy" is undefined in vscode on wsl VSCode - 构建后出现“无法解析不存在的文件”错误 - VSCode - Getting 'Unable to resolve nonexisting file' error after build 为什么 std::get_time() 简单示例无法在 WSL Ubuntu 20.04 上解析? - Why a std::get_time() simple example fails parsing on WSL Ubuntu 20.04? 无法在 WSL2 上运行 OpenGL - Can't run OpenGL on WSL2 cpp exe文件适用于wsl但不适用于windows10 cmd - cpp exe file working on wsl but not working on windows10 cmd 复制文件时是否可以自动建立不存在的目录? - Is it possible to make non-existing directories automatically when copying a file?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM