VS Code: Difference between revisions

From SciNet Users Documentation
Jump to navigation Jump to search
Added troubleshooting
Replaced content with "Visual Studio Code is documented on the Alliance wiki: https://docs.alliancecan.ca/wiki/Visual_Studio_Code That page covers the current modules and job examples for Trillium. For SciNet-specific access, see Trillium Quickstart."
Tag: Replaced
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
As of version 1.86, VS Code does not support CentOS 7 on the server side (see [https://code.visualstudio.com/docs/remote/linux 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.
Visual Studio Code is documented on the Alliance wiki:
https://docs.alliancecan.ca/wiki/Visual_Studio_Code


== Introduction ==
That page covers the current modules and job examples for Trillium. For
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.
SciNet-specific access, see [[Trillium Quickstart]].
 
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 [mailto:support@scinet.utoronto.ca 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 <code>~/.ssh/config</code> for OpenSSH clients. Add the following text
 
<pre>
Host niagara-rocky9
    HostName niagara.scinet.utoronto.ca
    User ccdbusername
    SetEnv XMODIFIERS=niagara-rocky9
    ForwardAgent yes
</pre>
 
and replace <code>ccdbusername</code> with your correct user name. The important bits here are to set the <code>XMODIFIERS</code> 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 <code>.bashrc</code> ==
In this step, we instruct the shell interpreter on Niagara to switch to the containerized environment when needed. Edit the file <code>~/.bashrc</code> '''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).
 
<pre>
if [[ -z "$NIAGARA_ROCKY9_ENABLED" ]] && [[ "$XMODIFIERS" == "niagara-rocky9" ]]; then
    export NIAGARA_ROCKY9_ENABLED=1
    exec /scinet/niagara/containers/rocky9
fi
</pre>
 
== 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: [[SSH#.28Optional.29_Using_ssh-agent_to_Remember_Your_Key|SciNet Wiki]], [https://docs.alliancecan.ca/wiki/Using_SSH_keys_in_Linux#Using_ssh-agent Alliance Wiki], [https://code.visualstudio.com/docs/remote/troubleshooting#_making-local-ssh-agent-available-on-the-remote VS Code troubleshooting page].
 
 
== Using VS Code now ==
At this point you can start VS Code and find <code>niagara-rocky9</code> 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 <code>ssh $HOSTNAME</code> 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 <code>kill-vscode-server</code>. Then start VS Code and connect again. Please report difficulties to [mailto:support@scinet.utoronto.ca SciNet support].

Latest revision as of 17:39, 9 November 2026

Visual Studio Code is documented on the Alliance wiki: https://docs.alliancecan.ca/wiki/Visual_Studio_Code

That page covers the current modules and job examples for Trillium. For SciNet-specific access, see Trillium Quickstart.