VSCode

Using SSH with VSCode

Our scope in supporting the Visual Studio Code editor is limited. If we confirm that SSH works outside of VS Code, and the following settings do not resolve your issue, we will suggest you cleanly remove and reinstall the application.

Visual Studio Code is used with the extension “Remote - SSH,” which must be installed before any of the following is relevant. VS Code can use either a “remote folder” or a git repo in a remote filesystem, but they both connect using the Remote - SSH extension.

Visual Studio Code: Remote-SSH has multiple moving parts. To answer common questions and issues, please familiarize yourself with the information below.

Lockfiles

When connecting to a remote, VS Code will prompt the user for an ssh password. When the ssh session is open, vscode will create-if-not-exists $HOME/.vscode-server, create a lockfile, and upload whatever data it wants to put on the remote.

In the event you are writing your files to your AFS home directory, vscode will be unable to create a lockfile there. Setting Lockfiles In Tmp to True will be required (see below). Different error messages are possible depending on whether vscode has successfully written to your home directory before. This may falsely appear to be an authentication error.

.vscode-server directory

If you are writing to a .vscode-server directory in AFS, it is possible that vscode will disconnect or appear to hang while file operations on the remote. This may be due to a very large number of files being accessed by vscode-server resulting in a slow response

If your only option is AFS, you may be able to delete the .vscode-server directory as a temporary fix. but you may still encounter performance-related issues in the future as it indexes your data.

If the remote host has a filesystem appropriate for your use, then you can choose a directory and add the host to the Server Install Path map (see below), so vscode can be installed without AFS.

Remote Execution

When you connect using VS Code Remote-SSH, it starts a node process on the remote system. This process stays running after you disconnect. See the VS Code Remote Development documentation.

This has implications for some things that rely on events that occur at login, such as updating group membership and obtaining tokens for AFS filesystem access. If you find that something works once, but fails after starting a new connection later, that’s a good clue that this could be involved.

If you have an issue related to the remote server, you should try running Kill VS Code Server on Host (see below) and if that does not resolve the issue, please also try closing all local vs code processes before connecting outside vs code in a terminal, then searching for .vscode-server processes and terminating each. (also below)

Configuration notes

⌘+Shift+P or Ctrl+Shift+P opens the “Command Palette”

Use the command palette to search for the following options as needed:

  -   set "Item" to the long hostname of the remote host, including `.csail.mit.edu`

  -   set "Value" to the directory where `.vscode-server` should be created

Do not set Server Install Path to /tmp, /scratch, or a similar shared directory on a shared server. It should be a directory no one else will choose.

  -  `ps ux | grep .vscode-server | awk '{print $2}' | xargs kill`

Reinstalling Visual Studio Code

If these suggestions fail and VS Code still has unexplained behavior, we can follow Microsoft’s clean reinstall instructions to delete all settings and user data and reinstall the application:

If you want to remove all user data after uninstalling VS Code, you can delete the user data
folders Code and .vscode. This will return you to the state before you installed VS Code.
This can also be used to reset all settings if you don't want to uninstall VS Code.
The folder locations will vary depending on your platform:

-   Windows - Delete `%APPDATA%\Code` and `%USERPROFILE%\.vscode`.

-   macOS - Delete `$HOME/Library/Application Support/Code` and `~/.vscode`.

-   Linux - Delete `$HOME/.config/Code` and `~/.vscode`.