天天看點

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

繼續閱讀