Developer environment setup#

Overview#

Throughout this semester, we will make regular use of bash, python, git, and other 3rd party command line tools such as azure-cli and gh-cli.

No matter what hardware you have available at home, everyone should be comfortable completing coding assignments on their personal computers and on classroom computers.

Everyone will need the following set up:

  • on a classroom computer:

    • a Debian WSL container with all class dependencies installed using apt

  • on personal computers:

    • If Windows: a Debian WSL container with all class dependencies installed using apt

    • If macOS: all class dependencies installed using brew

    • If Linux: all class dependencies installed using distribution package manager

The sections below show how to do that, and how to verify the installation, in each case.

Classroom computers: Linux WSL#

If using a Windows machine (lab computers and/or personal) for this course, you will need to set up Windows Subsystem for Linux (WSL).

Ensure necessary Windows software installed#

These programs should already be installed on your Windows machine, but in case they are not:

VS Code Extensions#

If you have not already, install VSCode.

Then, install the following extensions:

  1. Remote Development extension pack by Microsoft

  2. Python language support extension

  3. Python formatter/linter extension (ruff)

Install Debian WSL#

# Verify that Debian is an available OS to install
PS > wsl --list --online # Debian should be one of the results

# Install Debian
PS > wsl --install -d Debian

You will be prompted to create a username and password:

# Recommended: All lower case. Something easy to type, e.g. your first name
Enter new UNIX username:
# Recommended: Don't overthink this, you can always change this later
New password:

If you forget the password for your WSL container, you can easily reset it.

See the Microsoft article Set up your linux username and password.

After this, your installation is complete.

See the following links for more details if needed:

Configure terminal to use WSL#

Follow the steps in Set up Windows Terminal, particularly:

See Troubleshooting Windows Terminal for more details.

Install dependencies#

Perform system update#

# Update system:
sudo apt update && sudo apt upgrade -y

Install python#

# Install python3 as the default python
sudo apt install python3 python-is-python3

# Verify default python version is >= 3.9:
# NOTE: python-is-python3 makes "python" the same as "python3"
python --version
python3 --version

# Ensure pip is installed:
sudo apt install python3-pip
pip --version

# Ensure the python module venv is installed
sudo apt install python3-venv

# Ensure developer dependencies for python are installed
sudo apt install python3-dev

Set up git#

You’ll need to do the following to set up git on both your WSL:

sudo apt install git
git config --global user.name "Your Name"
git config --global user.email "youremail@domain.com"

See Installing Git for more detail if needed.

Install other needed tools#

We’re going to need the following packages:

sudo apt install man ssh wget ca-certificates rsync pass pass-extension-otp zbar-tools vim

Note

If, when running sudo apt install, you have an error like this:

E: Failed to fetch <url> 404 Not Found [IP: <ip>]
E: Unable to fetch some archives, maybe run apt get update or try with --fix-missing?

Make sure you update the system:

# you can also run sudo apt upgrade -y, but it's not necessary all the time.
sudo apt update

Then, try the installation command again.

I’ll keep this command updated throughout the semester as we encounter more packages we need.

Backup container to OneDrive#

Once the initial setup is complete, backups of the WSL container are easy to make.

Once a backup is made, it’s easy to:

  • recreate the exact same image on a new machine

  • restore your image in case the disk is wiped (this seems to be happening to our lab computers…)

Backup command#

First, let’s ensure you have a folder to keep your backups.

Recommendation: store WSL images on your college OneDrive account. That way, you can easily share your image with your personal computer, and restore your image automatically using any college computer.

PS > md -Force "C:\Users\<your-username>\OneDrive\420-6P3-W25"

Then, we’ll use wsl --export to make a backup copy of your WSL container:

# This can take around 5 minutes to finish.
PS > wsl --export Debian "C:\Users\<your-username\OneDrive\420-6P3-W25\debian.tar

Restore command#

On a new machine (or on a machine with a freshly wiped hard drive…) you can --import the backup image you created:

# This can take around 5 minutes to finish.
PS > wsl --import Debian .\Debian "C:\Users\<your-username>\OneDrive\debian.tar"

Note

After restoring WSL, you will find that you are automatically logged in as root instead of your username.

The way to set a default user in a WSL container instance is to create a [user] entry in the container’s /etc/wsl.conf file:

Open your wsl instance and add the following entry to /etc/wsl.conf:

/etc/wsl.conf#
[user]
default=username

Exit your distro/instance, then run a wsl --terminate <distroname> from PowerShell.

When you restart, the default user should be set to username.

For more detail: https://superuser.com/a/1627461

Personal computers#

Windows (WSL)#

After setting up WSL on a classroom computer, and backing up your WSL to OneDrive, the easiest way to set up WSL on your personal computer is to import your backup WSL image on your personal computer.

Note that any changes made to either container, after the import, will not be automatically synchronized.

If you are making many customizations, you might want to keep your backup up-to-date.

macOS / Linux#

On a terminal on your computer, install the packages below.

On OS X we’ll use brew, on Linux you can use your system’s package manager:

# Update system:
brew update && brew upgrade
# Verify python version is >= 3.9:
python3 --version
# Ensure pip is installed:
python3 -m pip install --upgrade pip

# Install other dependencies
brew install wget ca-certificates rsync pass pass-otp zbar vim

Also ensure you have installed VSCode and configured its extensions

Verify environment#

Your developer environment, whether on WSL, macOS, or Linux, should be able to run the following commands with the following results:

# Verify python version is >= 3.9 and pip is installed
python3 --version
pip3 --version # or pip --version

# Verify git config set up: ensure the output makes sense for you
git config user.name
git config user.email

# For the following no specific version is required
# but, these commands should not fail (show error message or exit error code 1)
man -V
ssh -V
rsync --version
pass --version
pass otp --version
zbarimg --version
vim --version