Lab: using VS Code & mantis
In this class, we'll be studying computer systems in part by using the C programming language and its relationship to the Intel x86 machine and assembly languages. To ensure that we all have a consistent computing environment, I would like you to do your work on the CS department's Linux server mantis.mathcs.carleton.edu. This short lab will help you get started working on mantis.
In case you want a demo of the elements of this lab, here's a short video explaining why we are working on mantis and demonstrating how.
See the bottom of this lab for brief notes on doing this on your laptop.
A run-through in 3rd Olin
- Login on the macOS side of a lab computer on the 3rd floor of Olin.
- Launch Visual Studio Code. (I'll call this VS Code or vscode from now on.)
- Open a remote window
- Hover your mouse over the little green (or blue) icon in the very bottom left corner of the VS Code window. You should see hover-text that says "Open a Remote Window". Click on the icon.
- At the top of the VS Code window, you'll now see a drop-down menu starting with "Connect to Host...". Click on "Connect to Host..."
- Now you'll see a new menu that says "+ Add New SSH Host". Don't bother
to click "Add New SSH Host" on the Olin lab computer, since anything you save
now will be lost when you log out. Instead, just type:
YOUR_USER_NAME@mantis.mathcs.carleton.eduand hit return.
- At this point, what VS Code asks you will depend on context. You may be asked for a password or you may be asked for an "SSH config file" or something along those lines. In the Olin labs, just follow your nose to the password-entry and then enter your password.
- If you connect successfully to mantis, a new window will open. That bottom-left icon will now say "SSH: mantis.mathcs.carleton.edu", which is the signal that you're ready to go.
- Open VS Code's file explorer. In the upper left corner, click on the two-pieces-of-paper icon that opens VS Code's file explorer. Then click on the Open Folder button that appears in the explorer. This will give you many choices, but you should go ahead and click OK for the default option, which should be /Accounts/YOUR_USER_NAME.
- Express your trust if asked. You may see a message asking if you trust the authors of the code you're looking at. Say yes, since you haven't written any code yet.
- Deal with "large workspace" warning.
You may see a warning panel that says "Unable to watch for file changes in this large workspace...".
Don't worry about this. This is always ignorable, but in any case, we'll fix this permanently in a minute.
- Set up a long-term working directory named cs208.
The file explorer at the left side of the VS Code window should now show you the top level of files in your CS/mantis account.
- Go up to the VS Code menu bar and select Terminal→New Terminal. A panel with a Unix prompt should appear in the bottom right of your VS Code window. That's a regular old Unix shell on the mantis server, and you can run any Unix commands you want there.
In that terminal, create a folder named "cs208" where you will do your work for the term.
mkdir cs208If you do "ls" after that, you'll see the new folder. You can also look at the VS Code file explorer, and the folder should show up there, too.
- Logout of mantis. Click on the bottom-left icon ("SSH: mantis.mathcs.carleton.edu"), scroll to the bottom of the resulting drop-down menu, and select "Close Remote Connection".
- Restart, but with the cs208 working directory. Login to mantis again, but this time when you click on "Open Folder", select your cs208 folder instead of your top-level directory. Open a terminal and you're ready to roll!
- Check the Open Recent menu. Take a look at the File→Open Recent menu for VS Code. Does it show "~/cs208 [SSH:mantis.mathcs.carleton.edu]"? If you were working on your own computer, that would be very convenient for future sessions. Sadly, that convenient menu item will be gone after you logout of the Olin computer.
- Logout when you're done
Doing this at home
- Get VS Code. Download and install Visual Studio Code
- Install the Remote - SSH extension. Launch VS Code. On the left edge of window, click on the Extensions icon (or select the View→Extensions menu). In the extensions browser, search for "SSH". The top result will probably be "Remote - SSH" by Microsoft. Install it.
- Off you go!. You should now be able to do all the stuff listed above.
- Downloading files from mantis. You can download files from mantis to your local machine (e.g., so you can submit homework via Moodle on your web browser) like so. In the VS Code file explorer, right-click on the file you want to download and select Download.