Skip to content

VSCode

Visual Studio Code is a popular development tool that is widely used by our researchers.

There are several ways to use Visual Studio Code with the YCRC clusters, depending on your specific application and/or preferences.

VSCode on Remote Desktop:

The easiest way to run VSCode is to use our Open OnDemand web portal. First, start a Remote Desktop interactive session. As noted in our Remote Deskop documentation, we recommend to adjust the 'image quality' slider bar all the way to the right if this is not the default. Then, to start VSCode, type the following in a terminal window within your Remote Deskop session:

module load VSCode
vscode

Setting up SSH tunneling to run VS Code Server on a cluster node

The above method will probably give most users a workable solution for using VSCode. However, one issue with the Remote Desktop is graphics responsiveness: particularly when scrolling, window behavior can become laggy and imprecise.

If this (or something else) is a problem for you, you can run VSCode on your local machine and set it up to remotely connect with YCRC clusters using an 'SSH tunnel'. The process is very similar the method we recommend for Jupyter notebooks. This is done with a batch script that starts up a VSCode server on a compute cluster node; you then connect to the server with your VSCode app on your local machine (i.e., your laptop).

Note

While you can also tunnel directly to the login nodes (several VSCode extensions allow VSCode users to connect to remote servers over SSH), this has some drawbacks: (1) the resulting connections can be unstable; (2) VS Code can initiate computationally expensive processes (compilers, etc) that put undue burden on our clusters' login nodes, where resources are limited.

  1. Create a vscode server batch script called vscode_slurm.sh and submit it to the queue with sbatch vscode_slurm.sh. The script source code is attached below.

  2. After this script successfully starts running, use the last line of the logfile vscode_slurm.txt (in the directory you submitted the job from) to set up a connection from the cluster to your own VScode app on a remote computer. The last line of vscode_slurm.txt will look like:

    To grant access to the server, please log into https://github.com/login/device and use code XXXX-XXXX
    

  3. Run your local VSCode app. Then, connect to the server from within the app as follows:

    • Go to the Welcome screen (Help -> Welcome)
    • Click Connect to...
    • Click Connect to tunnel...
    • Click Github
    • Click on your cluster node which should be listed as, i.e. r30406n03mccleary.ycrc.yale.edu

vscode_slurm.sh:

#!/bin/bash

#SBATCH --partition=day
#SBATCH -t 1-00:00:00
#SBATCH -c 1
#SBATCH --mem=10G
#SBATCH --output=vscode_slurm.txt

# vscode_slurm.sh

# Usage:

# sbatch vscode_slurm.sh

# After this script successfully starts running, use the last line of the
#  the logfile 'vscode_slurm.txt' (in the directory you submitted the job from)
#  to set up a connection from the cluster to your own VScode app on a remote computer.
#  An example last line will look like:

######################
# vscode_slurm.txt
######################
# ...
# To grant access to the server, please log into https://github.com/login/device and use code ​XXXX-XXXX
######################

# Note: if you will use a shared partition for this job, we suggest 
#  the 'day' queue. If many users start requesting multi-day jobs with this method,
#  it becomes more likely some users may accidently leave their
#  VSCode jobs running when not in use.
# This could lead to unnecessary resource consumption on the computing clusters.

module load VSCode

code tunnel

Troubleshoot: vscode_slurm.sh script fails

If you are unable to connect using this procedure, but it worked for you previously, it may be that VSCode was terminated abruptly and left a lock file hanging around. If the vscode_slurm.txt file created by the batch script contains repeated lines like:

warn error access singleton, retrying: the process holding the singleton lock file code server

then you can restore the ability to connect by removing the lock file as described in this link:

rm ~/.vscode/cli/tunnel-stable.lock                                                                                     

Code Server

The Code Server app launches an open source version of VSCode in a job on a compute node and opens in your web browser, providing a stable connection that is not subject to the strict limits on the login. To get started, connect to one of cluster Web Portals and choose Code Server from the Interactive Apps menu in the portal and then follow the instructions for launching an interactive app.


Last update: July 14, 2025