天天看点

VS Code的Error: Running the contributed command: ‘_workbench.downloadResource‘ failed解决

VS Code的Error: Running the contributed command: '_workbench.downloadResource' failed解决

转自:https://blog.csdn.net/ibless/article/details/118610776

1 问题描述

此前,本人参考网上教程在VS Code中配置了“Remote SSH”插件(比如这个教程),本人是在Windows中使用VS Code来连接远程的Linux服务器。但是今天使用遇到了问题

Error: Running the contributed command: '_workbench.downloadResource' failed

,截图如下:

VS Code的Error: Running the contributed command: ‘_workbench.downloadResource‘ failed解决

2 解决方案

  • 删除Remote Server上的

    ~/.vscode-server

    文件夹,可以在远程Linux服务器上执行

    rm -rf ~/.vscode-server

    指令
  • 在本地的VS Code中再次尝试连接,毫无意外,这次依然是失败的。但是这一步会在远程服务器中生成

    ~/.vscode-server/bin/xxx

    文件夹,此时可以看到一个名为

    vscode-server.tar.gz

    ,截图如下:
    VS Code的Error: Running the contributed command: ‘_workbench.downloadResource‘ failed解决
  • 上面的2d开头的文件夹称为Commit Id,现在利用Commit ID下载远程连接需要的文件。对于Stabe Version(在VS Code报错的的窗口中Ctrl+F搜索stable,有则为Stable Version)的Remote SSH插件,如下图,在“输出”窗口中Ctrl+F搜索“stable”。
    VS Code的Error: Running the contributed command: ‘_workbench.downloadResource‘ failed解决
  • 然后使用这个链接:https://update.code.visualstudio.com/commit:$COMMIT_ID/server-linux-x64/stable下载所需文件,注意链接中的$COMMIT_ID这几个字符(注意$不要忘记)需要换成自己的,比如我的是 2d23c42a936db1c7b3b06f918cde29561cc47cd6,那么此时我通过https://update.code.visualstudio.com/commit:

    2d23c42a936db1c7b3b06f918cde29561cc47cd6

    /server-linux-x64/stable就可以下载到我需要的文件。

    对于Insider版本,通过https://update.code.visualstudio.com/commit:$COMMIT_ID/server-linux-x64/insider这个链接下载相应文件。

  • 下载完毕后,将下载的文件upload到Remote Server的

    ~/.vscode-server/bin/xxx

    文件夹下,同时删除其他文件,最后再使用

    tar -xvf vscode-server-linux-x64.tar.gz --strip-components 1

    解压文件,具体如下图:
    VS Code的Error: Running the contributed command: ‘_workbench.downloadResource‘ failed解决
  • 然后使用

    chmod +x node server.sh

    为node和server.sh添加可执行权限。
    VS Code的Error: Running the contributed command: ‘_workbench.downloadResource‘ failed解决
  • 再次使用VS Code尝试链接,这一步会链接成功。

相关参考:

Using “Remote SSH” in VSCode on a target machine that only allows inbound SSH connections

继续阅读