Difference between revisions of "How to Setup Visual Studio Code for the ifarm"

From GlueXWiki
Jump to: navigation, search
m (Setup)
m
Line 34: Line 34:
 
# You should be prompted to enter a password, which will be your personal PIN + your current MobilePass code. Click enter and another prompt will appear. This time enter your JLab CUE password.
 
# You should be prompted to enter a password, which will be your personal PIN + your current MobilePass code. Click enter and another prompt will appear. This time enter your JLab CUE password.
 
# You should be taken to your home directory on an ifarm node. We now know the connection can be made. Type <code>exit</code> and click <i>enter</i> to close the session
 
# You should be taken to your home directory on an ifarm node. We now know the connection can be made. Type <code>exit</code> and click <i>enter</i> to close the session
## If you get the JEFFERSON LAB prompt but the connection is hanging, it may be that the ifarm node its routing you to is having issues. There are 3 nodes 1801, 1802, and 1901. Retry from step 1 but do <code>ssh ifarmXXXX</code> replacing the X’s with one of the three node numbers
+
## If you get to the JLab CUE prompt and enter your password but the connection is hanging, it may be that the ifarm node its routing you to is having issues. There are 3 nodes 1801, 1802, and 1901. Retry from step 1 but do <code>ssh ifarmXXXX</code> replacing the X’s with one of the three node numbers
 
# From the Command Palette run <code>Remote-SSH: Connect to Host</code>. Select the option '''ifarm'''
 
# From the Command Palette run <code>Remote-SSH: Connect to Host</code>. Select the option '''ifarm'''
 
## If you’d prefer a new window to not be opened, execute <code>Remote-SHH: Connect Current Window to Host</code>
 
## If you’d prefer a new window to not be opened, execute <code>Remote-SHH: Connect Current Window to Host</code>

Revision as of 16:37, 22 March 2024

Table of contents

Welcome! Have you ever wanted to edit code with smart code completion, integrated Git, syntax highlighting, intuitive debuggers, and so much more, all wrapped into one? Well look no further than Visual Studio (VS) Code! By the end of this guide you will be able to connect to the ifarm and have all these powerful tools right at your fingertips. If you run into any problems (especially if you have Windows machine, as this guide has only been tested for Apple devices) then please message me (Kevin Scheuer) over Slack and let me know!

Setup

Before beginning, please ensure you have the following:


The .ssh/config file

  1. Your first step for getting onto the ifarm will be creating a ssh config file, which dictates how your device, or “local machine”, will connect to the remote JLab server
  2. Open VS Code and navigate to the Extensions tab on the left hand sidebar. Copy and paste ms-vscode-remote.remote-ssh into the search bar, and install the package.
    1. If you can’t see the sidebar, try in the menu View > Appearance > Primary Side Bar
  3. In the menu bar go to View > Command Palette. Search and select Remote-SSH: Open SSH Configuration File
  4. Your default file is likely at /Users/YOUR_USERNAME/.ssh/config. Select this file.
    1. If not yet created, no worries. Open VS Code's integrated terminal with Terminal > New Terminal or View > Terminal and navigate to the .ssh folder. Run touch config to create a blank file. Open the file as instructed.
  5. If settings already exist in this file they can be kept, so long as they are not ifarm related. We will be using a slightly modified version from the JLab recommended config file. Download the custom config file and copy/paste its contents into the .ssh/config file open in the editor
  6. At the very bottom edit User YOUR_USERNAME_HERE and replace with your JLab CUE username
  7. Notice there is a dot next to the file name. This indicates edits have been made and need to be saved. Save the changes with File > Save and close the file by pressing the X next to the file name
  8. Open the command palette again and search/select Preferences: Open User Settings
  9. Search Remote.SSH: Remote Server Listen on Socket and ensure this option is selected.
  10. While we’re here, lets also change the default .vscode-server location. It will typically be placed in /home/YOUR_USERNAME/, but we don’t want this since it quickly takes up too much space. Its highly recommended to put this in a more spacious location like a user’s directory on the work disk. Search Remote.SSH: Server Install Path in your user settings, and set key to ifarm and Value to be your directory
    1. For example, mine is /w/halld-scshelf2101/kscheuer/
  11. Lastly, ssh needs a specific directory to be setup to work properly. Open a terminal and navigate to /Users/YOUR_USERNAME/.ssh/ (or wherever your config file is) and perform mkdir cm


Connecting

  1. Before we go about connecting with VS Code, let's test the config file and ensure the connection can be established. Open a terminal via Terminal > New Terminal or View > Terminal and simply run ssh ifarm. Note that even though the terminal is "integrated" as part of VS Code, for the most part it functions just like any terminal window
  2. You should be prompted to enter a password, which will be your personal PIN + your current MobilePass code. Click enter and another prompt will appear. This time enter your JLab CUE password.
  3. You should be taken to your home directory on an ifarm node. We now know the connection can be made. Type exit and click enter to close the session
    1. If you get to the JLab CUE prompt and enter your password but the connection is hanging, it may be that the ifarm node its routing you to is having issues. There are 3 nodes 1801, 1802, and 1901. Retry from step 1 but do ssh ifarmXXXX replacing the X’s with one of the three node numbers
  4. From the Command Palette run Remote-SSH: Connect to Host. Select the option ifarm
    1. If you’d prefer a new window to not be opened, execute Remote-SHH: Connect Current Window to Host
  5. It may ask what type of system this is, select Linux. Similar to the connection we did in the terminal, you will be prompted for 2 consecutive passcode inputs. The first will be the PIN+MobilePass, and the second your CUE password
    1. A popup may appear saying something like "the current operating system is not supported". Essentially, support for the ifarm's current operating system will drop by January 2025, but we will be updated by then so there's no need to worry about this
  6. VS Code will configure the connection, and if successful there should be a green status bar in the lower left corner. You can even open a terminal and see what node you are on, and verify that you are in your home directory
  7. Congratulations, you are now connected and ready to code! You can exit at any time by clicking on that green status bar and selecting Close Remote Connection.

Working With VS Code

Extensions

Troubleshooting