Setting up VSCode to work on the cluster

Visual Studio Code (VSCode) is general-purpose, freely available intergrated development environment. It is modular with extensions available for many different programming languages and file formats.

VSCode allows you to connect to the cluster from within the editor and work on your code directly on the cluster.

This section shows you how to set this up. It should work independent of whether you use VSCode on Windows, Linux or MacOS.

This functionality does not mean that you have to use VSCode. Other IDEs have similar functionality. If you want to use an IDE, you need to find the one best suited to your needs.

For ALICE users only
Version 1.86 of VSCode requires a more recent version of glibc and glibcxx than what is available on the cluster. Because these are system libraries, we cannot do much about on ALICE. When we migrate to new operating system this will be solved. Until then, we can only suggest to stay with version 1.85.X. (see also https://code.visualstudio.com/updates/v1_86#_linux-minimum-requirements-update)

Preparations

SSH Keys

The best way to connect to the through the cluster with VSCode is by using ssh keys. If you do not yet use ssh keys on the cluster, we recommend that first change your general connection the cluster to using ssh keys (see https://pubappslu.atlassian.net/wiki/spaces/HPCWIKI/pages/37748771 ).

If you have already been using ssh keys to connect to ALICE, you can in principle use your existing ssh key or create a new one specific for using with VSCode.

SSH config

You should set up a separate ssh config file for VSCode, because VScode wants to have write access to the ssh config if you use the manual setup. In order to avoid accidentally overwriting anything else in your ssh config, it is best to use a separate ssh config.

We would recommend setting up the ssh config for VSCode in advance because this is easier when working with an ssh gateway

First, we create a separate ssh directory to put the config file. Open a terminal on your Linux or MacOS computer or open PowerShell if you are on Windows and run:

mkdir ~/.ssh_vscode

Next, create a file config in the new directory. For simplicity, we can just open the file in VSCode from the command line (also PowerShell)

code ~/.ssh_vscode/config

Of course, you can use any other editor of your choice.

Now that the file is open, add host settings for at least one login node similar to what you have already done in your standard ssh config based on https://pubappslu.atlassian.net/wiki/spaces/HPCWIKI/pages/37748788 :


ALICE

Host alicegw HostName ssh-gw.alice.universiteitleiden.nl User <username> ServerAliveInterval 60 IdentityFile ~/path/to/private/ssh/key Host alice2vsc HostName login2.alice.universiteitleiden.nl User <username> ProxyJump alicegw:22 ServerAliveInterval 60 IdentityFile ~/path/to/private/ssh/key

where you need to replace <username> with your ALICE user name.

Replace ~/path/to/private/ssh/key by the actual path to the ssh key that you want to use

You can also use another login node on ALICE.


SHARK

where you need to replace <username> with your SHARK user name.

Replace ~/path/to/private/ssh/key by the actual path to the ssh key that you want to use

You can also use another login node on SHARK.

If you are connecting from within the LUMC network, you do not need the ProxyJump setting for the host shark2vsc


Set up VSCode

First, you need to install an extension. Open VSCode and go to Extensions. Then search for the extension “Remote - SSH” ( https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-ssh ) and install it.

After it was installed and activated, go to “Preferences -> Settings” and search for “remote.ssh”.

In the list of settings that has appeared, look for “Remote.SSH: Config File” (probably the first one in the list) and specify the full path to your ssh config, e.g., /home/<username>/.ssh_vscode/config (Linux) or C:\Users\<username>\.ssh_vscode\config (Windows) where “<username>” is your user name on your local workstation.

It is best to verify that VSCode can find your ssh config. Type either “F1” or go to “Help → Show All Commands” and type in “Remote-SSH: Open SSH Configuration File”. After hitting enter, it should show you a drop-down menu with the path to the ssh config that you just specified. When you click on it, it should open the file.

Connecting with VSCode

When the config file is set up correctly, you can type “F1” or go to “Help → Show All Commands” and search for “Remote-SSH: Connect to Host”. This should show you the host alias for VSCode that you have defined in your ssh config (e.g., “alice2vsc” or “shark2vsc”) as an option. If it does, hit enter and wait. VSCode will probably open a new window and initialize. This takes a few seconds and then it should show you in the bottom right corner that you are connected.

You can open folders on the cluster just like you would on your local workstation. If you open a git repository, then you can use the git workflow in VSCode.

For ALICE users only, VSCode might complain that the cluster does not use git 2.0 or greater. While there are git modules for version greater than 2.0, the system version is 1.83. However, as far as we can see, it still works.

Your local VSCode will remember that opened a folder on the cluster which allows you to quickly reconnect.