Written by Chris Gregg, Julie Zelenski and others, with modifications by Nick Troccoli and Lisa Yan
This guide walks you through all the steps to start working on assignments in CS111. Just like in CS107, you will complete all your programs for CS111 by SSHing into the myth cluster, which is a set of computers in Gates B08 running Linux (Ubuntu 14) and have various open source tools installed (gcc, gdb, etc.) that we will use.
SSHing Into Myth
The first step is to set up your own computer to log in to myth via SSH. The instructions for doing this are the same as from the CS107 getting started guides - if you need a refresher, see this guide for info on logging in:
Open CS107 Getting Started Guide
Choosing a Text Editor
For CS111, you are welcome to choose any text editor you'd like. You can use a terminal editor while SSHed into myth such as Emacs or Vim, which means you are editing the files directly on myth to minimize version mishaps. Alternatively, you can use a local graphical editor that you install on your own computer that can edit remote files, such as Sublime Text or Visual Studio Code - however, there is a slightly higher risk of version mishaps as you are editing files locally and transferring them back and forth on opening/saving. The course staff is also not always able to help troubleshoot local editor issues since we may not be familar with the installation/setup process, though we will do our best. Here are notes for various editors you might choose:
Emacs (Terminal Editor)
Check out the CS107 guide to Emacs here. Make sure to download the CS107 Emacs configuration file, by executing the following command immediately after logging into myth:
wget https://web.stanford.edu/class/cs107/resources/sample_emacs -O ~/.emacs
Vim (Terminal Editor)
Check out the CS107 guide to Vim here. Make sure to download the CS107 Vim configuration file, by executing the following command immediately after logging into myth:
wget https://web.stanford.edu/class/cs107/resources/sample_vimrc -O ~/.vimrc
Visual Studio Code / VSCode (Local Editor)
Visual Studio Code is a local graphical editor you can download to your computer. It supports editing remote files by downloading them to your local machine and re-uploading them when saved. You still compile, run and test your program using the terminal, but you can edit your files using a graphical editor. Check out this video if you'd like to get set up with Visual Studio Code to work on your assignments:
Here is the configuration you need from the video:
Host mythXX
User YOUR_SUNET_ID
HostName mythXX.stanford.edu
ServerAliveInterval 60
ControlMaster auto
ControlPath ~/.ssh/%r@%h:%p
ControlPersist yes
- Replace XX with a random number between 51 and 66 - click here to generate one
- Replace
YOUR_SUNET_IDwith your sunet ID. - On Windows, follow these instructions (under "How to install OpenSSH using Settings") to ensure you have ssh installed if you haven't already installed it.
- Remove the ControlMaster/ControlPath/ControlPersist configurations if you're using Windows.
- Remember to uncheck
Lockfiles In Tmpand uncheckUse flockin your VSCode settings before connecting. If you have problems, try doing Ctrl+Shift+P (Win/Linux) or Cmd+Shift+P (Mac) and running the "Kill VS Code Server on Host..." command on the myth machine you're using.
Troubleshooting / FAQ
- if you get a "permission denied" error when you are SSHing into myth via VS Code and can't access any files, try running
kinit && aklogto refresh your credentials - it should prompt you for your password again and you should be good to go. - if you get an error "Could not fetch remote environment" and "Error: WebSocket close with status code 106", you'll need to go back to an earlier version of the "Remote - SSH" package (a later one introduced an issue). Go to the extensions screen and select the "Remote - SSH" extension, and click the downward error next to "Uninstall" and choose "Install Another Version". Then choose version 0.74. Reload it and you should be good to go.
- (courtesy of CS106L) Sometimes, when you quite VS Code and reopen, the SSH password prompt gets stuck on a loop and won't let you log in. If this is happening to you, press command + shift + P on Mac or ctl + shift + P on Windows and type "kill", and select the option "Remote-SSH: Kill VS Code Server on Host". Now enter your password again and you should be good to go.
- If you get an error "Could not establish connection, cannot find module minimist", Log into myth via a separate terminal program and as soon as you log in (from your home directory), execute
rm -rf .vscode-server. Be careful with this command, however, as it force deletes without confirming first; so make sure you execute this right after you log into myth. Then restart VS Code and try again.
Sublime Text (Local Editor)
Sublime Text is another local graphical editor you can download to your computer. It supports editing remote files by downloading them to your local machine and re-uploading them when saved. You still compile, run and test your program using the terminal, but you can edit your files using a graphical editor. You will need to download Sublime Text as well as the "SFTP for Sublime Text" package, which adds the capability to edit remote files.
Download Sublime Text Download SFTP for Sublime Text
Once you set up SFTP for Sublime Text, add a new server by selecting the "Edit Server" command, and in the server configuration change "host" to "myth.stanford.edu", "user" to your SUNET ID (e.g. "troccoli") and "remote path" to "/afs/ir/users/t/r/troccoli", where the "t" is replaced with the first letter of your SUNET ID, the "r" is replaced with the second letter of your SUNET ID, and the "troccoli" is replaced with your full SUNET ID.
Working on Assignments
CS111 uses the same set of tools (make, sanitycheck, submit, gdb, valgrind) as CS107. If you need a refresher on the workflow for compiling/testing/submitting assignments, check out this CS107 guide:
Open CS107 Guide to Working on Assignments
The CS107 Debugging Guide has tips for approaching debugging and using GDB and Valgrind: