Debug Remote Code using GitHub Copilot

Debug Remote Code using GitHub Copilot
Photo by Mohammad Rahmani / Unsplash

For most developers, using VS Code for a series of programming tasks is perfectly normal, and recently, under the guidance of GitHub Copilot, we can easily enhance developers' coding capabilities in VS Code by installing the GitHub Copilot extension.

However, in certain situations, such as when local development is on ARM based but the program development only support an x86_64 environment, and the development environment does not exist on our local computer, we need to setup the environment elsewhere for development. VS Code itself supports the Visual Studio Code Remote - SSH extension


Problem

At this point, you might encounter a problem. If you wan to use GitHub Copilot while developing in a remote Linux environment, you're find the VS Code CANNOT utilize the GitHub Copilot feature in the remote SSH environment. You'll need to make some specific configuration to your VS Code for it work

Solution

We will use the built-in capabilities of VS Code's Extension Host to solve the problem. Specify that GitHub Copilot should run on the local UI side, rather than executing inside the Workspace

  • Open settings.json (or Ctrl + Shift + P)
  • Type "Preferences: Open User Setting (json)"
  • Add the following configuration to settings.json
    "remote.extensionKind": {
        "pub.name": ["ui"],
        "GitHub.copilot": ["ui"],
        "GitHub.copilot-chat": ["ui"],
    },

settings.json

Screenshot settings.json
  • Reload or Restart VS Code

We ensure that both publisher.extensionName and GitHub.copilot prioritize execution through the local UI via the above settings, thereby resolving the issue where GitHub Copilot fails to function when using Remote SSH in VS Code.

Read more