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.
I've made a short video explaining why we need to work on mantis and demonstrating how, but you probably won't need it.
See the bottom of this lab for brief notes on doing this at home.
A run-through in our labs
- Login on a lab computer on the 3rd floor of Olin.
- Open the application Visual Studio Code. (I'll call this VS Code or vscode from now on.)
- Hover your mouse over the little green 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.
- 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.
- You may see a message asking if you trust the authors of the code you're looking at. Say yes.
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.
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, let's 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.
- Let's 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".
- Now start over and login to mantis again, but this time when you click on "Open Folder", select your cs208 folder (/Accounts/YOUR_USER_NAME/cs208) instead of your top-level directory. Open a terminal and you're ready to roll!
Doing this at home
- Download and install Visual Studio Code
- Launch VS Code. On the left edge of window, click on the Extensions icon. In the extensions browser, search for "SSH". The top result will probably be "Remote - SSH" by Microsoft. Install it.
- You should now be able to do all the stuff listed above.
- Downloading remote files to your local machine (e.g. so you can submit homework via Moodle on your web browser): In the VS Code file explorer, right-click on the file you want to download and select Download.