无法在 Windows 上运行的 VSC 上调试 R 代码

HuL*_*iCa 4 r visual-studio-code

我已经为在 Windows 上运行的 VSC 安装了以下扩展:R、R 调试器和 R 工具,但是,当我尝试调试某些 R 代码时,我收到以下消息:Please install the R package: "vscDebugger"

我尝试使用安装它install.packages("vscDebugger", repos="http://cran.us.r-project.org"),但失败了。

这是我的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": [
        {
            "type": "R-Debugger",
            "name": "Launch R-Workspace",
            "request": "launch",
            "debugMode": "workspace",
            "workingDirectory": "${workspaceFolder}"
        },
        {
            "type": "R-Debugger",
            "name": "Debug R-File",
            "request": "launch",
            "debugMode": "file",
            "workingDirectory": "${workspaceFolder}",
            "file": "${file}"
        },
        {
            "type": "R-Debugger",
            "name": "Debug R-Function",
            "request": "launch",
            "debugMode": "function",
            "workingDirectory": "${workspaceFolder}",
            "file": "${file}",
            "mainFunction": "main",
            "allowGlobalDebugging": false
        },
        {
            "type": "R-Debugger",
            "name": "Debug R-Package",
            "request": "launch",
            "debugMode": "workspace",
            "workingDirectory": "${workspaceFolder}",
            "includePackageScopes": true,
            "loadPackages": [
                "."
            ]
        },
        {
            "type": "R-Debugger",
            "request": "attach",
            "name": "Attach to R process",
            "splitOverwrittenOutput": true
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

我收到所有选项的错误。

小智 8

@HuLu 发布的答案不是正确的答案,因为它使用了他自己的 R 和 vscode 位置,此问题的真正解决方案来自 R 调试器扩展本身。

错误描述中指出:

该扩展正在开发中,您应该尝试命令 r.debugger.updateRPackage

因此,现在如果 vscDebugger 没有显示并且您在手动安装时遇到错误,请尝试:

@command:
r.debugger.updateRPackage
Run Code Online (Sandbox Code Playgroud)

或者命令:

Ctrl + Shift + P
R Debugger: Update or install the required R Package
Run Code Online (Sandbox Code Playgroud)

选择此选项时,将执行与 @HuLu 提到的非常相似的命令。