VS Code

From SciNet Users Documentation
Jump to navigation Jump to search

As of version 1.86, VS Code does not support CentOS 7 on the server side (see here). The implication is that remote development is no longer compatible with Niagara. The easiest solution that is currently working is to continue using version 1.85, if that is possible. Otherwise, one could try to implement the workaround described below.

Update: as of version 1.86.1 VS Code is working again on Niagara without going through the procedure below (but support may be dropped again in a future version, see link).

Introduction

In this workaround you will make VS Code connect into a containerized environment that has newer versions of the operating system libraries. While this environment runs on Niagara, it is mostly isolated in terms of software. Thus, running software (modules, virtual environments, code that you have compiled, job submission) within this environment may not work or cause unexpected issues. It should be enough though for VS Code to install the server components and provide at least basic functionality. It is recommended to use the built-in terminal in VS Code to SSH out of this container to a normal Niagara login node, where normal functionality will be available in the shell, as described below.

This procedure is a "hack" and may or may not provide full functionality, or work at all. Unfortunately we cannot guarantee anything, and provide this recipe "as is". Nevertheless, please contact SciNet support to report any issues, as we may be able to make some improvements.

Adding special host configuration

In this step, you add a new host to your SSH configurations on the client side (i.e. your laptop or workstation). That is typically done by editing the file ~/.ssh/config for OpenSSH clients. Add the following text

Host niagara-rocky9
    HostName niagara.scinet.utoronto.ca
    User ccdbusername
    SetEnv XMODIFIERS=niagara-rocky9
    ForwardAgent yes

and replace ccdbusername with your correct user name. The important bits here are to set the XMODIFIERS environment variable in the remote (i.e. on Niagara), and enabling SSH agent forwarding, which will enable authentication to "escape" the container after VS Code has started.

Modifying .bashrc

In this step, we instruct the shell interpreter on Niagara to switch to the containerized environment when needed. Edit the file ~/.bashrc on Niagara and copy the text into the top of the file. Be very careful in this step, since incorrect definition in this file could prevent you from connecting to Niagara altogether (if that happens, only a system administrator would be able to revert the change).

if [[ -z "$NIAGARA_ROCKY9_ENABLED" ]] && [[ "$XMODIFIERS" == "niagara-rocky9" ]]; then
    export NIAGARA_ROCKY9_ENABLED=1
    exec /scinet/niagara/containers/rocky9
fi

Starting SSH agent

This step is not mandatory, but necessary if you want to escape the containerized environment in the built-in terminal in VS Code. Prior to starting VS Code, start an SSH agent on your laptop or workstation and make sure your appropriate (CCDB) keys are added. See these links for help on the topic: SciNet Wiki, Alliance Wiki, VS Code troubleshooting page.


Using VS Code now

At this point you can start VS Code and find niagara-rocky9 in the list of remotes. You can connect to it normally and find your working directory on Niagara. If you started an SSH agent as described in the previous step, you should be able to open the terminal and type ssh $HOSTNAME and get a normal bash shell on one of the Niagara login nodes. You may also SSH into Mist if that is needed.

Troubleshooting

Some issues can be solved by restarting the server process. To do that, close all VS Code windows, connect to Niagara normally via SSH and run the command kill-vscode-server. Then start VS Code and connect again. Please report difficulties to SciNet support.