RSS

Build a Dev environment on Windows WSL + VS Code

How to build a Dev Environment on Windows, that doesn’t suck too much
Share this page:

Why use Windows?

Cause your Mac or Linux is on repair. In my case, my Mac is getting a free screen replacement, and the other old PC I have has one of those new BIOS with non breakable password, and CMOS is not accessible (loser alert!!!).

Other reasons? Maybe your company policy is Windows Only (hint: update your CV…). So… how do you survive? Luckily, VS Code is awesome, and WSL… well, doesn’t suck. Keep reading…

Turn Developer Mode & WSL

WSL is Windows Subsystem Linux. Basically, you run an actual Ubuntu on your Windows. It’s easy. You need to have Windows 10, and a 64 bit CPU.

Go to “Type to Search” and type “Developer”. Since Windows is an environment made for developers (detect_sarcasm: ON), you’ll only have one menu option, as shown in the screenshot below, and choose Developer mode:

Enable Developer Mode

Open PowerShell as Administrator and run:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

You’ll need to restart your PC. After you do, go to Apps, and search for Linux. I’d recommend Ubuntu.

TIP All the packages you’re installing, you need to install on Ubuntu, not Windows. Be carefull, cause when you go to python.org, you’ll automatically be offered a Windows version.

TIP Don’t use the default Ubuntu terminal on Windows. It’s horrible, you can’t even copy and paste stuff. Instead, enable WSL as Default View on VS Code and use that one,.it’s the same like on Linux or Mac. Keep reading.

Set VS Code to use WSL by default

You’re gonna want to do this, because the native WSL Ubuntu terminal in Windows is horrible… you can’t even paste text. And PowerShell won’t do for Linux.

Super simple in the last version.

Terminal - New Terminal. On the upper right side of the terminal, you’ll see a dropdown with 1: powershell or something similar. Click on it and go to “Select Default Shell”, and choose WSL. Done!!!

wsl-vscode.png

Where the hell are my WSL files?

For some reason, Linux files are not presented in Windows Explorer, so you need to know the path. Just write this down, your Linux file system is here:

\\wsl$

So go to your VS Code, and Open Folder -> \\wsl$\home\...

Update: There is a better option, the instructions I found here. The idea is to Install Remote Development Extension Pack. After the remote extension is installed, you will see a colored button in the left-bottom corner of VS Code, named “Open a remote window”. Click it and select “Remote-WSL: New Window” to open a window with remote environment enabled. Some setup work will be done now and you should see the progress in the right-bottom corner.

Install Git

You need Git on both, Windows and WSL, cause otherwise your VS Code won’t sync well with Git:

  • VS Code will redirect you to git-src.org, and you can install it from there. You need it to get your VS Code to sync with your branches, regardless from where you switch between master, dev etc.
  • For Ubuntu you can use the standard apt inistall git, and configure your environment, as shown below.
sudo apt update
sudo apt install git

git config --global user.name "Your Name"
git config --global user.email "youremail@yourdomain.com"

And there you go! An almost Unix-like experience. Why almost? Well… it’s still Windows, it’s going to be laggy, kill you with infinite updates, when you’re deploying a heavy package - browser will be super slow, no internal process priorization… But you knew that when you signed up, right? lol

Enjoy!