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

VS Code中使用R语言时工作区为空、无法附加R环境的问题求助

VS Code中使用R语言时工作区为空、无法附加R环境的问题求助

各位大佬好,我最近在VS Code里用「R Extension for Visual Studio Code」插件写R代码时遇到了棘手的问题,想请教大家帮忙排查下:

我能正常执行一些基础的R操作,比如定义向量、绘制图表,代码示例如下:

test <- c(10, 12, 15)
plot(test)

但奇怪的是,VS Code的R工作区始终是空的,完全看不到我存储的变量;而且状态栏里的R标记显示「未附加」,点击它还会弹出报错:

Error in .vsc.attach() : could not find function ".vsc.attach"

我已经参考相关方案修改了VS Code的settings.json配置,现在的配置内容如下:

{
  "security.workspace.trust.untrustedFiles": "open",
  "workbench.colorTheme": "Default Dark Modern",
  // R Options
  "r.rterm.windows": "C:\\Program Files\\R\\R-4.3.1\\bin\\R.exe",
  "r.rpath.windows": "C:\\Program Files\\R\\R-4.3.1\\bin\\Rterm.exe",
  "r.lsp.debug": true,
  "r.lsp.diagnostics": true,
  "r.alwaysUseActiveTerminal": true,
  "r.rterm.option": [
    "--no-save",
    "--no-restore",
    "--r-binary=C:\\Program Files\\R\\R-4.3.1\\bin\\R.exe"
  ],
  "terminal.integrated.profiles.windows": {
    "PowerShell": {
      "source": "PowerShell",
      "icon": "terminal-powershell"
    },
    "Command Prompt": {
      "path": [
        "${env:windir}\\Sysnative\\cmd.exe",
        "${env:windir}\\System32\\cmd.exe"
      ],
      "args": [],
      "icon": "terminal-cmd"
    },
    "R": {
      "path": [
        "C:\\Program Files\\R\\R-4.3.1\\bin\\R.exe"
      ]
    },
  },
  "terminal.integrated.enableMultiLinePasteWarning": false,
  "security.workspace.trust.startupPrompt": "never",
  "security.workspace.trust.enabled": false,
  "terminal.integrated.defaultProfile.windows": "R",
  "terminal.integrated.enablePersistentSessions": false
}

补充说明:我后来怀疑问题的根源可能是我的用户文件夹名称里包含瑞典语字母「å」,除了修改用户名之外,有没有其他可行的解决办法呀?

备注:内容来源于stack exchange,提问作者KGB91

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.20 12:50:25