DEV Community

Cover image for Epic Development Environment using Windows Subsystem for Linux
John Woodruff
John Woodruff

Posted on • Edited on • Originally published at johnbwoodruff.com

Epic Development Environment using Windows Subsystem for Linux

NOTE: There is an updated version of this article using WSL 2. Check it out here!

Cross-posted from Epic Development Environment using Windows Subsystem for Linux on Medium

Like many other developers, I have a handful of side projects I am working on at all times. My work is also my hobby. Whenever a new side project appears, I immediately pursue it because of the excitement of working on something new and shiny! I often feel like the developer in this comic by the excellent CommitStrip was written about me.

West Side-project Story

West Side-project Story - CommitStrip - Nov 25, 2014

To support all these side projects, I obviously need an awesome machine to do this work on. I wanted to separate my work laptop and code from my personal projects. So, I decided recently that I’d purchase myself a new laptop on Black Friday. For what I wanted, however, I couldn’t convince myself to shell out that much money for a Mac. I could, however, buy a Windows laptop with all the specs I wanted (and more) for a much cheaper price. With that in mind, I researched for days, and found what I believed to be the perfect laptop! Come Black Friday, I snapped it up.

I finally had my perfect laptop and was ready to go. The last obstacle? Setting up a legit development environment. I was initially worried due to having used Linux and macOS for development the last few years. Lucky for me, Windows 10 with the latest Creators Update has fantastic improvements to the Windows developer environment. At the center of it all? Windows Subsystem for Linux, or WSL.

Yep. You can run multiple Linux distros, on your Windows PC, without virtualbox, dual booting, etc. This is native. And this is awesome.

WSL Distros

Image from New distros coming to Bash/WSL via Windows Store

I’m still in the early days of using it for my personal development, but it’s been a wonderful experience thus far! Vastly easier and better (IMHO) than trying to wrangle cygwin, git for windows with the bash emulation, and the many other solutions that attempt to bridge the gap to a *NIX experience. So, let’s dig in to how you can get this epic dev environment on your Windows machine.

Prerequisites

In order to use these instructions, you must be running Windows 10, updated to at least the Fall 2017 Creator’s Update. For the section on Docker, you must also have a machine that can use Hyper-V and hardware virtualization, something that requires Windows 10 Pro.

Install Ubuntu with WSL

Enable WSL

The first thing you need to do is enable WSL. Open “Turn Windows features on or off”, then in the dialog that appears, scroll down and check the box “Windows Subsystem for Linux” then select Ok. This will apply the changes, and reboot your machine when required.

Once you have WSL enabled, open the Windows Store and search for “Linux”. You’ll see a large banner prompting you to check out the Linux distros. At the time of writing, those were Ubuntu, openSUSE, and SUSE Linux Enterprise Server.

I chose Ubuntu as I am far more experienced with it. This article uses Ubuntu commands. Once you’ve installed the Ubuntu app from the Windows Store, open it and run lsb_release -a to see that yes, you are indeed running Ubuntu itself on your Windows machine.

Git

Many of the installations further on in this article require git. I decided to install and run git through WSL. To install, simply run sudo apt update && sudo apt install git. Upon installing git, I also generated an SSH key, as I would need to use that for pulling from and pushing to all my repos later. This is very simply accomplished by running: ssh-keygen -t rsa -b 4096 -C "your_email@example.com".

ZSH (Optional)

This next step is completely optional. I love bash, and I love zsh, so either one works fine. If you prefer bash, skip this section.

It’s fairly straightforward to install zsh. After making sure you’ve run sudo apt update then install it with sudo apt install zsh. You can test to make sure it’s working by running zsh which should bring you into a zsh terminal!

I also love oh-my-zsh, which provides lots of beautiful themes and excellent plugins. I used the curl command under the Basic Installation instructions, and I was good to go! You can then select the theme you want by editing your ~/.zshrc file and adding the theme name to the ZSH_THEME environment variable. Personally, I’m using Pure, a beautiful minimalist theme.

Pure Theme

Featured image from the Pure repository

NOTE: Personally, when trying to use Pure and zsh with the Ubuntu terminal app, it had some styling and unicode issues. This is not a problem for me, however, as I use Hyper, which I go over below!

Hyper

Hyper by Zeit is one of my favorite things I love having on all my machines. It’s a beautiful terminal emulator with plugin and theme support. It was one of the first things I installed after installing WSL and Ubuntu. To get it working, simply open up your .hyper.js file and change the shell property to shell: 'wsl.exe' then save and close the file. Once you get back into Hyper, it should load up your zsh (or bash) terminal! From here on out, I exclusively use Hyper for all my terminal needs.

NOTE: Make sure there are no arguments in the shellArgs property. WSL by default uses the login shell.

Hyper Plugins

In case anyone out there hasn’t used Hyper, there are some good plugins I use that I recommend adding to your .hyper.js plugins array. They include hyperterm-material-dark, (disclosure: that’s my theme) hypercwd, hyper-tabs-enhanced, and for those moments of awesomeness, hyperpower!

Visual Studio Code

Even more than Hyper, Visual Studio Code is possibly my favorite piece of software ever. I’ve used IDEs, Sublime Text, Atom, Notepad++, I’ve tried almost all of the most used ones. VS Code is by far my favorite editor. It’s beautiful, incredibly lightweight, super fast, has tons of amazing extensions, built in debugger support, and is as close to full IDE functionality as any text editor I’ve ever used. I installed this as quickly as I could and brought down all my settings using the Settings Sync extension. (which I highly recommend using to sync settings across devices)

I bring this up because I have the integrated terminal in VS Code also set to use my WSL shell. To do this, I set the following setting: "terminal.integrated.shell.windows":"C:\\WINDOWS\\System32\\wsl.exe". Once you open the integrated terminal, you should be good to go!

Node.js/NPM

Personally I decided to take the approach of doing as much as absolutely possible inside of the WSL environment. Also, I am obsessed with NVM for managing my Node installs, which doesn’t work on Windows. So, instead of downloading the installer for Node.js for Windows, I installed nvm through Ubuntu’s repositories! You can follow the directions on NVM’s Installation Instructions. I used curl to download the install script, which I installed by running sudo apt install curl.

If you did everything right, you should have nvm installed correctly. I then installed the Long Term Support version of node by running nvm install --lts and then nvm use --lts to set it as the version I’m currently using. I also set it to my default node version by running nvm alias default {VERSION} where VERSION is the version number you just installed.

NOTE: I initially had some struggles where when I opened my Ubuntu terminal, it would give the error: N/A: version "N/A" is not yet installed After a bit of searching, I found that when I ran nvm ls it would list the installed versions of node. Under the lts versions, several had “N/A” because they were not installed. I installed those versions, and it stopped giving me the error.

Npm

A global npm install of the Angular CLI repository

Yarn

As an aside to installing Node, I thought I’d bring up that I also installed Yarn, because I love Yarn. You can install it through Windows, but again, I’m trying to do everything I need through WSL, so I followed the Linux Installation Instructions. Specifically the Ubuntu/Debian instructions, of course. This went without a hitch, and I had yarn working!

Yarn

A yarn install working beautifully

Docker

First off, before we get into this, it is important to note that in order to run Docker for Windows, which makes use of Hyper-V virtualization, you must be running Windows 10 Pro. The Home edition does not have support for Hyper-V. This does not mean you can’t run Docker. You can still run Docker Toolbox, which uses VirtualBox. These instructions, however, only apply to Docker for Windows.

This is the one thing that I didn’t install through WSL. I installed Docker for Windows, due to its tight integration with the operating system. The experience with the Windows version is perfect for me, so I didn’t feel the need to install this using WSL. Perhaps down the road I’ll experiment with this.

I did, however, make it accessible from my WSL environment. After installing Docker for Windows (I had to go into the BIOS on startup and enable hardware virtualization as an extra step) and it was successfully running, I simply aliased it so it would be invoked the same way as on Linux/Mac. To my .zsh_aliases file, I added the following lines:

alias docker='docker.exe'
alias docker-compose='docker-compose.exe'
Enter fullscreen mode Exit fullscreen mode

Upon restarting my terminal, I could invoke docker and docker-compose commands just like normal!

Docker

Docker for Windows being run through my zsh shell using the alias

Last Words

First, massive props to Rich Turner and the rest of the team working on Windows Subsystem for Linux. They’re doing insane things to make life on Windows for the regular developers like me vastly easier and more enjoyable. Not all heroes wear capes, and these guys are definitely my heroes!

Finally, there will definitely be much more down the road in terms of tools and software that I’ll end up needing. Like I said previously, it’s still early days for me in terms of my usage of this development environment. I’m sure I’ll come across some annoyance I hadn’t run into previously. Every environment has those annoyances, however, and thus far I’ve been loving developing on Windows. I’ll be honest, that’s something I never thought I would say!

Latest comments (41)

Collapse
 
iplaman profile image
Idan Bidani

With all the anti virus and IDS apps monitoring files on windows running on my laptop, the performance of files operations are 60 times slower than a linux VM running on the same laptop.

Collapse
 
barryblando profile image
Barry⚡

About terminal theming, it's really epic. Using hyperjs + oh-my-zsh w/ Powerlevel9K + hack font complete.

Powerlevel9K + Hack Font Complete

Collapse
 
ristep profile image
Rste Panovski

I prefer just to install ubuntu and erase windows 😊

Collapse
 
johnbwoodruff profile image
John Woodruff

Always an option for those who prefer that! :)

Collapse
 
bmarkovic profile image
Bojan Markovic

Given WSL limitations and assuming that the laptop is to be used solely for software development on those personal projects, what's stopping you from going all in and running a Linux distro directly?

Collapse
 
johnbwoodruff profile image
John Woodruff

So personally the limitations with WSL are such that they haven't affected me in the stuff I use it for. I've definitely gone full Linux before, I used it as my primary driver for something like 4 years. However I only used it to the extent that I can do with WSL, and I MUCH prefer the stability and application quality of Windows 10. With WSL I get both things with no compromise! (again, in terms of my stuff I use it for) I absolutely acknowledge that there are many people for whom a full linux distro is absolutely the better option.

Collapse
 
bmarkovic profile image
Bojan Markovic • Edited

Fair enough. I must admit that I haven't used WSL for about a year (and I must admit that even then it was a begrudging compromise because Win10 was a company policy at a former employer).

I ran into multiple issues with symlinks and filesystem access from Windows to Linux and vice versa, various networking problems and also, some software simply did not run.

Containers (and on my dev boxes I run both Docker and LXC, the latter as low cost VM hosting for Ops/networking related emulated setups) simply weren't an option.

Very happy to be back on Linux. Also software stability isn't, in my experience, better on Win10, I'd actually put it the other way around. Admittedly that greatly depends on what software we are talking about.

But then, I have not been that happy with Mac either, especially Python situation on it though my experience with homebrew was overall better than with WSL. Still, nothing beats the real thing.

I do understand people have issues with incompatible hardware but I select my hardware with Linux compatibility in mind (which is kinda what Apple does).

Thread Thread
 
johnbwoodruff profile image
John Woodruff

All valid concerns! I'm a Mac user at work and I personally love the stability, along with the unix shell. I don't do much Python on my Mac so I can't speak much to that.

In terms of symlinks back and forth between the WSL and Windows filesystems, they absolutely were not well supported 1+ years ago. The anniversary update fixed all those issues, and I personally am using symlinks with no issue.

I should say that I do really enjoy using a full Linux distro. I just hate switching back and forth between my Windows and Linux partitions, so the marriage between the two works great for my needs. :)

Collapse
 
mustyt profile image
Mustapha Taiwo

Hmm.. Interesting article. But NVM does support/is supported on windows... Nevertheless, will give it a try someday.

Collapse
 
johnbwoodruff profile image
John Woodruff

Thanks! In terms of nvm, the actual nvm library doesn't support Windows, as is called out in their README under Important Notes. However there are two alternatives they mention, which are separate projects maintained by other people. So while there are alternatives, I wanted the actual nvm library, not a port or a clone. Hence using it in WSL.

Collapse
 
haikal00 profile image
haikal00

what is the advantage of this feature over cygwin/babun?

Collapse
 
johnbwoodruff profile image
John Woodruff

Cygwin runs modified linux binaries, whereas WSL simply provides a layer in between a full Ubuntu user space and the Windows Kernel, so that WSL can run any unmodified linux binary. Simply install it from apt-get and you're good to go. Cygwin also provides only a specific set of packages, whereas with WSL you can install anything available from a PPA.

Collapse
 
rogererens profile image
Roger Erens

I'm not clear on how you installed Hyper. Is it the Linux version or the MS Windows version? In the former case, one needs to install gdebi first, correct?

And its plugins cannot be installed until npm has been installed, right?

Collapse
 
johnbwoodruff profile image
John Woodruff

So this is actually a Windows app. You can download it from here: hyper.is/

Since it's a GUI application you won't be able to install the Linux version.

Collapse
 
rogererens profile image
Roger Erens

Hi John,

Thanks for your elaboration!

I already thought you used the Window version (it wouldn't make sense starting hyper from cmd), but further down the article you mention in the Docker section that Docker is the one thing you did not install through WSL, hence I became unsure about your installation procedure for Hyper (and VSCode) since they are cross-platform.

BTW: if you install MobaXterm or XMing (both can start an X Window server in Windows) and add DISPLAY=:0 to your .bashrc, you can start GUI applications in WSL (e.g. gitk)

Collapse
 
nek_dev profile image
Maxime Veber

Interesting. Thanks!

I use WSL too and I really like mintty terminal: github.com/mintty/wsltty (It's far more stable than hyper, but I have to admit that hyper is probably the future)

About Docker, it simply does not work inside WSL. ( :'( ) We still need to run it inside a VM.

Collapse
 
e_doxtator profile image
edoxtator

I think that having options is always a good idea, but I can't deal with Windows clunky UI. I'm a Mac user right now, but I think my next laptop purchase will be a blank canvas so I can just install Linux and be done with it-- I spend more time in that environment than I do anywhere else.

Until then, I've been using Parallels (or VMWare, depending on need) for the past several years. I've never had any serious issues with a VM, and I haven't experienced the "I'm not a real boy" issue you've mentioned.

I have tried Visual Studio Code on the Mac. It's not overwhelming. Not enough to make me switch from vim.

Collapse
 
kzagoris profile image
Konstantinos Zagoris

For MacOS switchers, there is a homebrew for wsl/linux called surprisingly linuxbrew

Collapse
 
johnbwoodruff profile image
John Woodruff

Cool! Never seen this project before! I'll have to check it out and see how well it works!