Getting Started

NOTE: this website is out of date. This is the course web site from a past quarter, Fall 2023. If you are a current student taking the course, you should visit the current class web site instead. If the current website is not yet visible by going to cs111.stanford.edu, it may be accessible by visiting this link until the new page is mounted at this address. Please be advised that courses' policies change with each new quarter and instructor, and any information on this out-of-date page may not apply to you.

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. 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 - 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 (supports Windows/Mac/Linux). 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.

Having any issues during installation or when editing files on Myth? Check out our VSCode troubleshooting section further down the page for some fixes.

  • Install VSCode: download it from the Visual Studio Code website (Mac users may need to drag the app from their Downloads folder into the Applications folder)
  • Install CS111 VSCode configuration profile: We have created a profile that includes the remote SSH extension and configuration to access Myth, as well as interface layout preferences for easy editing. If you already use VSCode, this will not overwrite any existing configuration; it will install a separate profile called "CS111", and you can toggle between profiles at any time by clicking the gear icon in the bottom left of VSCode and selecting "Profiles". Click here to install. The VSCode web interface will pop up - click the left side button "Create Profile in Visual Studio Code" to install the profile on your local machine. Once VSCode opens, click "Create Profile" and follow the steps to install everything included in the profile.
  • (WINDOWS ONLY) Install SSH: follow these instructions (under "How to install OpenSSH using Settings") to ensure you have ssh installed if you haven't already installed it.
  • Add myth machine login: open the command palette and enter "SSH Configuration", and select the option "Remote-SSH: Open SSH Configuration File". Select the filename with your personal computer user account in it (e.g. something like /Users/nicktroccoli/.ssh/config). Add the following lines at the end of the file and save it - replace YOUR_SUNET_ID with your sunet ID. (note: the config text below includes a randomly generated myth number just for you in order to distribute users across the myth machines)

Mac/Linux:

Host mythXX.stanford.edu
  User YOUR_SUNET_ID
  ServerAliveInterval 60
  ControlMaster auto
  ControlPath ~/.ssh/%r@%h:%p
  ControlPersist yes

Windows:

Host mythXX.stanford.edu
  User YOUR_SUNET_ID
  ServerAliveInterval 60
  • Log in to myth: open the command palette and enter "Connect to host", and select the option "Remote-SSH: Connect to Host". Select the myth machine name that appears (which should match the one you just entered in your config), and a new window should open (you can close the old one). It may prompt you to enter your myth (same as Stanford/Axess/etc.) password at the top of the window. (Not accepting your password? Try logging in once via a standalone terminal program first (like Terminal on Mac); sometimes myth will require two-step authentication the first time you log in from a new location. From that point onwards, you can then log in via VSCode.). After a little bit (it may take 30sec or so the first time), it should connect and you should see a green area in the bottom-left corner of the window change from "Opening Remote..." to "SSH: mythXX.stanford.edu".

  • Open terminal: in the top VSCode toolbar, click "Terminal" -> "New Terminal" and it should open a terminal window connected to the myth machine. You can use this to run, compile, debug, etc. just like you can do in a separate terminal program.
  • (Recommended) Create a myth folder for CS111: in the terminal, make a new folder (mkdir) for your CS111 work this quarter - that way it's all in one place.
  • Open files: click the "files" icon at the top of the left toolbar and click the "Open folder" button. A menu should pop up listing the contents of your myth home directory; select the folder you would like to open in VSCode (e.g. the one you previously created for CS111) and press "OK". (If it asks you if you want to trust the authors of the folder, select "Yes"). Now it should appear in the left sidebar and you can click any files you add there to open and edit them. When you save them, they will be automaticallly synced back to the myth machines.

From now on, when you launch VSCode, you can re-connect by running "Remote-SSH: Connect to Host" from the command palette, and selecting myth.

VSCode Troubleshooting

  • If VSCode doesn't accept your password when logging in to myth: try logging in once via a standalone terminal program first (like Terminal on Mac); sometimes myth will require two-step authentication the first time you log in from a new location. From that point onwards, you can then log in via VSCode.
  • If you can view files on myth but can't edit them due to permission issues: run kinit && aklog in the terminal to refresh your credentials - it should prompt you for your password again and you should be good to go.
  • Error "Could not fetch remote environment" and "Error: WebSocket close with status code 106": switch to an earlier version of the "Remote - SSH" extension (a later one introduced an issue). Click the extensions tab and select the "Remote - SSH" extension, and click the downward arrow next to "Uninstall" and choose "Install Another Version". Then choose version 0.74. Reload it and you should be good to go.
  • SSH prompt stuck on a loop: (courtesy of CS106L) 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.
  • "Server installation process already in progress - waiting and retrying": try the "Kill VS Code Server on host" step mentioned above, and possibly more than once in a row; or try the rm -rf .vscode-server command mentioned below.
  • Above steps not fixing the issue? Try deleting the VSCode configuration files installed for you on myth. 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 make, gdb, and valgrind to compile and debug, and the custom sanitycheck, submit tools to test and submit (these are the same as used in CS107). Check out this CS107 guide for more information on the workflow for compiling/testing/submitting assignments, which is the same in CS111:

Open CS107 Guide to Working on Assignments

The CS107 Debugging Guide has tips for approaching debugging and using GDB and Valgrind:

Open CS107 Debugging Guide