You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VS Code 1.89连续调试C++失败:提示No such file or directory

第二次调试C++代码时终端报“No such file or directory”

第一次按F5能正常调试C++代码,但第二次调试时终端会输出No such file or directory错误。之前功能正常,近期才出现这个问题。关闭集成终端后重新调试可恢复,但操作繁琐。

我的launch.json配置

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/build/test.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "Set Disassembly Flavor to Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

第二次调试的终端输出

Alex@Alex_Asus MINGW64 ~/Documents/GameEngine/EngineTest
$  /usr/bin/env c:\Users\Alex\.vscode\extensions\ms-vscode.cpptools-1.19.9-win32-x64\debugAdapters\bin\WindowsDebugLauncher.exe --stdin=Microsoft-MIEngine-In-c2axmb5z.gjq --stdout=Microsoft-MIEngine-Out-5qxnf0rp.y1x --stderr=Microsoft-MIEngine-Error-itnz0wk4.tmp --pid=Microsoft-MIEngine-Pid-iod3xchz.rmb --dbgExe=C:\MinGW\bin\gdb.exe --interpreter=mi

Alex@Alex_Asus MINGW64 ~/Documents/GameEngine/EngineTest
$ ^C

Alex@Alex_Asus MINGW64 ~/Documents/GameEngine/EngineTest
$ \ms-vscode.cpptools-1.19.9-win32-x64\debugAdapters\bin\WindowsDebugLauncher.exe --stdin=Microsoft-MIEngine-In-dob4gqtf.x31 --stdout=Microsoft-MIEngine-Out-r1qtapcf.vwn --stderr=Microsoft-MIEngine-Error-sysmwcem.542 --pid=Microsoft-MIEngine-Pid-s2l523nn.m1i --dbgExe=C:\MinGW\bin\gdb.exe --interpreter=mi
bash: \ms-vscode.cpptools-1.19.9-win32-x64\debugAdapters\bin\WindowsDebugLauncher.exe: No such file or directory

Alex@Alex_Asus MINGW64 ~/Documents/GameEngine/EngineTest
$

解决办法

从终端输出能看到,第二次调试时命令开头的/usr/bin/env c:\Users\Alex\.vscode\被截断,只剩\ms-vscode.cpptools-...,导致路径无效。可以尝试以下方案:

  • 强制每次调试创建新终端
    在launch.json的配置项里添加"console": "newExternalTerminal",这样每次调试都会新开一个终端,避免复用旧终端时的路径截断问题。修改后的配置片段如下:
{
    "name": "(gdb) Launch",
    "type": "cppdbg",
    "request": "launch",
    "program": "${workspaceFolder}/build/test.exe",
    "args": [],
    "stopAtEntry": false,
    "cwd": "${fileDirname}",
    "environment": [],
    "externalConsole": false,
    "console": "newExternalTerminal", // 新增该行
    "MIMode": "gdb",
    "miDebuggerPath": "gdb",
    "setupCommands": [
        // 原有命令保持不变
    ]
}
  • 更新VS Code的C++扩展
    你当前使用的是ms-vscode.cpptools-1.19.9版本,属于较旧版本,可能存在终端复用的bug。更新到最新版本的C++扩展,多数旧版本终端问题已被修复。

  • 检查终端路径配置
    打开VS Code设置,搜索terminal.integrated.profiles.windows,确认MINGW64终端的配置路径正确,也可尝试重置终端配置为默认值。

内容的提问来源于stack exchange,提问作者Alex

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.24 20:00:20