Setting up a Linux Dev Environment in Windows with WSL (Windows Subsystem For Linux) (general_development)
I’ve been using WSL as a dev environment on my laptop for a couple years. This week something updated itself and things stopped working. I had to uninstall everything and re-install it. I thought I’d write down the steps I took to get it working again.
Install WSL
-
Follow these instructions to install WSL
- In powershell run:
wsl --install
This will install and set up WSL. It should also install the default Linux distro (Ubuntu).
I had some issues where it didn’t actually install any distro. Run
wsl -l
to see what distros are installed. If all you see isdocker-desktop
and dockerdocker-desktop-data
then you need to install a distro. Runwsl --list --online
to see what distros are available. I installed Ubuntu 20.04 LTS. Runwsl --install -d Ubuntu-20.04
to install it.-
It will then prompt you to create a user account.
-
Update and upgrade the packages:
sudo apt update && sudo apt upgrade
Windows Terminal
- Install the Windows Terminal from the Microsoft Store. The link above has some good steps to customize the terminal.
VS Code
-
Install VS Code
-
Install the Remote - WSL extension. For me, this caused the biggest headache. To get it to work I had to install an old version (v0.66.3). The latest version caused the WSL extension to terminate. It gave a lot of errors related to “could not resolve authority”
-
Set up extensions in vs code
- Spell Checker
- GitLens
- Git Graph
- Vim
- change the setting
"vim.useCtrlKeys": false
to disable the ctrl keybindings. This way you can use ctrl-c to copy and ctrl-v to paste.
- change the setting
Git
- Configure git identity
git config --global user.name "Your Name"
git config --global user.email "
- Create an ssh key for GitHub
ssh-keygen -t rsa -f ~/.ssh/id_rsa -b 4096
- Go to the GitHub SSH Settings Page and create a new key. Paste in the contents of the file
~/.ssh/id_rsa.pub
Bash setup script
- Install useful software
- Miniconda
- Docker
- Docker Compose
- Fish Shell
- There is a bash script in my dotfiles repo that installs all of this stuff. You can find it here
git clone git@github.com:mharty3/dotfiles.git
Oh my fish
- Set up Fish Shell with Oh My Fish Theme
Close and reopen the terminal before and after this step.
curl https://raw.githubusercontent.com/oh-my-fish/oh-my-fish/master/bin/install | fish omf install agnoster conda init fish
Install a powerline font
To get the fish terminal to properly display, you’ll need a powerline font (or “Nerd Font”). I installed Cascadia Code PL (ttf variable is recommended): https://github.com/microsoft/cascadia-code/wiki/Installing-Cascadia-Code