Engineer's Guide To Windows: WSL
These days I mostly write Ruby, and from what I hear, it’s a nightmare on Windows proper.
Ruby on pure Windows is a dead end for Rails and pointless investment of time imo, improving Ruby on "Windows Subsystem for Linux" should be a priority though, and bootsnap makes it bearable. https://t.co/arM3UJrPYD
— Sam Saffron (@samsaffron) March 25, 2019
Thanks to the Windows Subsystem for Linux (WSL), enough of the headaches have been smoothed out for me to give this a shot.
The Windows Subsystem for Linux lets developers run a GNU/Linux environment -- including most command-line tools, utilities, and applications -- directly on Windows, unmodified, without the overhead of a traditional virtual machine or dual boot setup.
Enabling WSL
Starting from a clean slate, it's time to start the Linux adventure.
I followed along with a helpful Microsoft article to get up and running. First, open up an admin PowerShell window, and enable the WSL feature with
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
It’s important to end up with WSL 2 because of all of the performance improvements, so make sure to grab all of the Windows updates to get at least to version 1903 with build 18362. Then enable the Virtual Machine platform with
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Make sure to restart the computer! Something I missed at first. Once that's done, download and run the Linux kernel update package
https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
Now pop back into an admin Powershell to set the default WSL version to 2 with
wsl --set-default-version 2
Finally, head over to the Microsoft Store to find your favorite Linux distribution, Debian, and download/install that.
Virtualization Issues
Even if WSL avoids “the overhead of a traditional virtual machine,” it still takes advantage of virtualization tech. Initially, when I tried to open up the Debian app, I hit Error 0x80370102
.
After some digging, I found that this meant some virtualization features on my system weren’t enabled. I have a newer Ryzen build and found a BIOS setting for SVM (AMD Secure Virtual Machine) Mode, disabled. Once I flipped that on and booted back into Windows, I was back in business.
Wrapping Up
Once successfully installed, create a primary user with a secure password, update with the system package manager, and hang tight for the next time where I’ll be getting my development environment ready for my day-to-day work!
Bonus: Windows Terminal
Microsoft has been doing a great job with their tooling for developers, and the Windows Terminal app is no exception! Grab it from the Microsoft Store, and it can be a great alternative to the more basic terminal experience you get from the WSL apps themselves.
Windows Terminal is super customizable, and all from editing an easy to read JSON file. Check out the documentation for the various options and even some cool custom color schemes.