olNGIb4NkK5r2x7x4oG3GpEzizVpnY6KNCck9cym

如何讓自建部署的 Code Server 能夠使用 Visual Studio Code (VS Code) 的擴充插件市集?

自建部署的 Code Server 無法使用 Visual Studio Code 的擴充插件市集,需要再額外進行設定才可以。

筆者前陣子心血來潮在桌邊角落的香橙派(OrangePi)開發板上部署了 Code Server 服務,想著只要有瀏覽器便可以快速地調試一些小腳本。然而卻發現服務中的擴充插件市集(Extensions Marketplace)與 Visual Studio Code (VS Code) 編輯器不同。根據官方文件中的說法:

One major difference is in regards to extensions and the marketplace. The core of VS code is open source, while the marketplace and many published Microsoft extensions are not. Furthermore, Microsoft prohibits the use of any non-Microsoft VS Code from accessing their marketplace.

簡而言之就是雖然微軟(Microsoft)公司開源了 Visual Studio Code (VS Code) 的核心程式碼,但擴充插件市集則否,並且根據微軟公司的服務條款中所述,擴充插件市場只能和 Visual Studio Code 一起使用,因此 Code Server 提供了 Open-VSX 擴充插件庫。

在官方文件中有提及這個擴充插件庫並不完美,也希望它變得越來越好,但筆者真的覺得太難用了……於是查了一些資料,想說到底要 如何讓自建部署的 Code Server 能夠使用 Visual Studio Code (VS Code) 的擴充插件市集

皇天不負苦心人,竟然在 CSDN 上的這篇文章中看到了一個簡單的解決方案!解決辦法十分地簡單,是使用編輯器開啟 /usr/lib/code-server/lib/vscode/product.json 設定文件,並添加以下內容:

  "extensionsGallery": {
    "serviceUrl": "https://marketplace.visualstudio.com/_apis/public/gallery",
    "cacheUrl": "https://vscode.blob.core.windows.net/gallery/index",
    "itemUrl": "https://marketplace.visualstudio.com/items",
    "controlUrl": "",
    "recommendationsUrl": ""
  }

編輯儲存之後,只需要重新啟動 Code Server 服務即可:

$ sudo systemctl restart code-server@$USER

張貼留言