53 views
 owned this note
<!--- TODO LIST: - change username to <username>, machine to <machine> and at the beginning explain that the user should replace these (+ example of stbc-i1) - list of troubleshooting/FAQ/known issues - specifically mention the duplicate .vscode-server directories that interfere --> # Guide for using vscode to develop on stbc This guide is aimed at people who would like to use an IDE to develop/write code on a Nikhef machine. I've written down the process for Visual Studio Code (vscode) since that's what I use. The first step consists of setting up an SSH connection to your preferred Nikhef machine (probably one of the stbc nodes). The second step is configuring vscode to connect to the Nikhef machine using SSH. In the following instructions please replace `<username>` with your actual username, and `<machine>` with the machine you use (for example `stbc-i1`). ## Setting up an SSH connection There is already a guide on how to do this, see [Nikhef SSH documentation](https://kb.nikhef.nl/ct/SSH_access_and_configuration.html). In short, you should have `.ssh` folder in your home directory on your local machine that contains a public key, private key, and a config file. The config file should contain at least the following: ``` Host *.nikhef.nl User <username> Host stbc*.nikhef.nl stbc* User <username> ProxyJump login.nikhef.nl ``` In case you want to connect to a machine that's *not* one of the stbc nodes you need to replace the 2 instances of `stbc*` with the hostname of the machine you want to connect to. If you use an ssh-agent then you may need to provide some more configuration details, please see the section on agent forwarding in the Nikhef SSH documentation. ## Setting up your Visual Studio Code remote These steps are compiled mostly from personal experience, with Ubuntu 20.04. They are heavily inspired by the official vscode documentation: [Remote Development using SSH](https://code.visualstudio.com/docs/remote/ssh) 0. Install vscode 1. Install the Remote-SSH extension if it is not already installed 2. Make sure the vscode remote server doesn't install in your Nikhef home directory! It is already more than 100MB by itself, and any extensions you want to use on the remote will be installed here. To do this, open vscode settings and look for the setting "server install path". Add an item with the machine in the item field, and the path in the value field, like this: `<machine>.nikhef.nl` and `/project/<experiment>/users/<username>`, where you should put the relevant `<experiment>`. Note that you have to create this directory manually first, in case you have not done so before! 3. Now you can setup the remote connection. Press `f1` or `ctrl+shift+p` and select `Remote-SSH: Add New SSH Host...` 4. It will ask for an SSH connection command, use `ssh <username>@<machine>.nikhef.nl -X -Y` 5. Next it asks you to select your SSH config file (probably `/home/user/.ssh/config`) 6. Done! There should be a new entry in your ssh config file that looks like this: ``` Host <machine>.nikhef.nl HostName <machine>.nikhef.nl ForwardX11 yes User <username> ``` To connect, press again `f1` or `ctrl+shift+p` and select `Remote-SSH: Connect to Host...` (or `Remote-SSH: Connect Current Window to Host...` if you don't want to open a new window). You can also click on the icon on the bottom left that looks a bit like `><`. The first time it will install the server, this should only take a few seconds. After it is done, check that the server `.vscode-server` is installed in the correct path. To disconnect, press `f1` or `ctrl+shift+p` and select `Remote: Close Remote Connection`, or click on the icon on bottom left. ## Extensions Depending on the extension, it will usually run either on your local machine or on the remote machine (usually the extension itself knows what it wants). Extensions that need to run on the remote need to be installed there, you can do this in the usual way when connected to the remote. ### C/C++ Extension Pack I still have to figure out if this works correctly, so no promises! - IMPORTANT! The memory used by the C/C++ extension is not limited by default, so it can in principle use all the RAM on stbc! To prevent this, set `C_Cpp: Max Memory` to a sensible value like 4096 (4Gb) - this should be more than enough. Also check if `C_Cpp: Intelli Sense Memory Limit` has a sensible limit. - Also make sure the cache isn't on your home directory at nikhef, since this gets full quite easily: In the setting `C_Cpp: Intelli Sense Cache Path` for the Remote put a path to your /data or /project directory, for example: `/project/alice/users/<username>/.vscodecache`. - If you want vscode to recognize functions and methods from ROOT, O2Physics, etc. you have to tell it where to find them. If you have installed the software according to ALICE instructions, the paths you have to add to the Include path settings are of the form `.../alice/sw/slc7_x86-64/ROOT/latest/include/**`. You can do this by pressing `f1` and `C/C++: Edit configurations (UI)`. In priciple you can use wildcards if you want to add all packages (ROOT, pythia, O2Physics, ...) in one go: `.../alice/sw/slc7_x86-64/*/latest/include/**`, but I haven't managed to get this to work yet... - You may also need to specify a different compiler than the system one it picks automatically. In the compiler path setting put the following: `.../alice/sw/slc7_x86-64/GCC-Toolchain/v12.2.0-alice1-5/bin/gcc` - Furthermore it may be good to put the `Cpp Standard` setting to c++17, make sure that you put this setting for "Remote", not "User".