Introduction
This article aims to provide a step-by-step guide on how to use Visual Studio Code (VSCode) for remote R Perl code debugging on a Linux High Performance Computing (HPC) cluster without requiring admin rights. The process involves setting up an SSH connection from VSCode to the HPC cluster and configuring debugging settings.
Prerequisites
- A Linux HPC cluster with SSH access
- VSCode installed on your local machine
- An SSH client installed on your local machine (OpenSSH is recommended)
- R and Perl installed on the HPC cluster
Setting up the SSH Connection
First, you need to configure SSH keys for passwordless authentication between your local machine and the HPC cluster:
$ ssh-keygen -t rsa -b 4096 -C "[email protected]"
$ eval "$(ssh-agent -s)"
$ ssh-add ~/.ssh/id_rsa
Next, copy the public key to the HPC cluster:
$ cat ~/.ssh/id_rsa.pub
$ pbcopy < ~/.ssh/id_rsa.pub
$ ssh user@hpc_cluster 'cat > ~/.ssh/authorized_keys'
Configuring VSCode for Remote Debugging
First, install the Remote - SSH extension:
$ code --install-extension ms-vscode-remote.remote-ssh
Next, create a new folder on the HPC cluster:
$ mkdir ~/my_project
Copy your R and Perl scripts to this folder:
$ scp path/to/your/script.R user@hpc_cluster:~/my_project/
$ scp path/to/your/script.pl user@hpc_cluster:~/my_project/
Open VSCode and select "Remote-SSH: Connect to Host" from the "File" menu:
File > Remote-SSH: Connect to Host
Host: user@hpc_cluster
Once connected, VSCode will display the remote file explorer:
Configuring Debugging Settings
Create a new .vscode/launch.json file:
{
"version": "0.2.0",
"configurations": [
{
"name": "R (SSH)",
"type": "R",
"request": "launch",
"port": 8787,
"serverReadyAction": {
"action": "openExternally",
"pattern": "http://localhost:8787"
},
"miDebuggerPath": "/usr/bin/rdebug",
"sourceFileMap": {
"remote.rootPath": "~/my_project",
"localRootPath": "${workspaceFolder}"
},
"preLaunchTask": "R: Build Workspace"
},
{
"name": "Perl (SSH)",
"type": "perl",
"request": "launch",
"program": "${workspaceFolder}/script.pl",
"args": [],
"cwd": "${workspaceFolder}",
"mime": [
"text.x-perl"
],
"port": 5000,
"miDebuggerPath": "/usr/bin/gdb"
}
]
}
Debugging R Code
To debug R code, simply click the debug icon in the left sidebar:
Debugging Perl Code
To debug Perl code, you need to install the gdb debugger on the HPC cluster:
$ sudo apt-get install gdb
Then, start the debugger from VSCode:
In this article, we have covered how to use VSCode for remote R Perl code debugging on a Linux HPC cluster without requiring admin rights. The process involves setting up an SSH connection, configuring VSCode for remote debugging, and creating debugging settings for R and Perl.