DEV Community

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

Posted on • Updated 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!

Top comments (41)

Collapse
 
erebos-manannan profile image
Erebos Manannán

Docker for Windows is often a very bad idea, as it requires Hyper-V and Windows can't support Hyper-V and whatever other emulation Virtualbox and VMWare use at the same time. This is an issue for a lot of devs who use e.g. Vagrant boxes to work in multiple projects, such as me. There is Docker Toolbox, but it's mostly a mess, old, and probably completely unsupported.

Annoyingly also the WSL has massive limitations, there are some hacks around some of the limitations but mostly it's useless for my needs.

Symlinks between the different filesystems have ended up creating some very peculiar situations, Windows drive always has 0777 perms so e.g. SSH keys won't be trusted, you can't actually launch VMs directly from WSL without some hack to make them actually use Vagrant/Docker/similar on Windows side, which has it's own issues again. No sound, no built-in X support, no 32-bit compatibility, ...

In short, there's a massive list of issues that can easily block someone from using these tools effectively, and annoyingly Microsoft's official answer to many of these complaints on their uservoice has been that they don't plan to fix them. They clearly plan to keep the WSL a 2nd class citizen in their world, with mostly an advertising value to be able to say "hey developers, you can totally work on Windows with your *nix tools".

Collapse
 
johnbwoodruff profile image
John Woodruff

Interesting, I haven't run into any issues with Docker for Windows yet, but I'll now keep my eye out. It might be a good reason to install docker from the Ubuntu PPA instead of aliasing Docker for Windows. Thanks for the tip!

I'm sure with some use cases WSL has some serious roadblocks. Thankfully for web and OSS development, I haven't run into any limitations as of yet with their latest release. I definitely had lots of issues in the past, as I've been messing around with it ever since they released their first technical preview of it. It just keeps getting better, though, and their latest update closed all the gaps I had personally come across.

Collapse
 
erebos-manannan profile image
Erebos Manannán

Have you actually checked if you can run native Docker in WSL? I would assume you cannot, as much of the "exotic" parts of the kernel are just disabled, and you can't e.g. launch normal Virtualbox VMs from it, quite likely that containers don't work either.

Also blogs.msdn.microsoft.com/commandli... etc. seem to hint at it not being an option.

Collapse
 
mohessaid profile image
Mohammed E. MEZERREG

Totally agree with you. I face all of what you mentioned about virtual machines, Docker and filesystems. Now I use Docker Toolbox with Nanobox for my developments and to be honest It kills me everytime I work with it. The best solution for me was to get two machines. One for Windows related developments and the other for Web developments. This way I don't care about support for Windows.

Collapse
 
andrespineros profile image
Andrés Felipe Piñeros

I agree. Please don't think that WSL is an actual replacement for a full linux distro. For advanced kernel requirements, just use a VM or a dual boot.

Collapse
 
erebos-manannan profile image
Erebos Manannán

Oh and if anyone is interested where is this UserVoice for WSL: wpdev.uservoice.com/forums/266908-...

Collapse
 
aveeshkumar profile image
aveeshkumar

Hello John,

Great article - loved the comic strip. I switched from Windows 7 to Ubuntu Linux several years ago and now run Win 7 in Virtual Box.

I do have a Win 10 laptop and with Virtualization support in BIOS - I use Virtualbox (and guest additions for Shared Folders/clipboard) and guest OS Ubuntu Server/Desktop (and other OS's)

Why would WSL be better on the laptop?

Collapse
 
johnbwoodruff profile image
John Woodruff

So personally, I like to avoid VMs wherever possible. I used to code in an Ubuntu VirtualBox VM, and it was just not my favorite, since I never felt truly "native". Not to mention interop with Windows programs was difficult if not impossible. That's why I love WSL so much, is because it's all "native". Obviously we're not running the entire Ubuntu (or the distro of choice) operating system and kernel, but it's the closest thing natively on Windows.

In my opinion though, you should definitely use whatever you're most comfortable with. I happen to dislike VMs enough that this WSL setup is a joy for me to use. If you like your VM setup though, then I would say that's the best option for your situation. :) I'd never presume to tell anyone that my setup is better than theirs haha.

Thanks so much for reading my article! :)

Collapse
 
aveeshkumar profile image
aveeshkumar

Thanks for your reply!

I agree - I think it is a choice/requirement between what one feels "native" is

But I will try WSL....sometime!

Collapse
 
anku profile image
Ankit Tiwari

I have been using WSL for over a year now. I love it. My setup is almost same as yours.

As good as the WSL is, it is still quite buggy. I use CMD along with Ubuntu.

Do you know how WSL gets update? Is it via Microsoft Store? If so, where is the changelog?

Collapse
 
johnbwoodruff profile image
John Woodruff

The subsystem itself updates along with Windows updates. I believe bug fixes occur regularly with regular windows bug fix updates. Redstone 4, coming very soon, has a bunch of updates/new features and a number of bug fixes. Some of them are listed in this blog post.

The distros you install through the Windows Store are the user spaces for those distros, and I imagine those get occasional updates, although I've never specifically noticed/checked.

Collapse
 
yemolai profile image
Romulo G Rodrigues

Hey, you just made me love zsh after so many years struggling to try it! Oh, and "terminal.integrated.windowsExec" preference key in VisualStudio gives me an "Unknown configuration setting", maybe you were trying to say "terminal.integrated.shell.windows"?

Collapse
 
johnbwoodruff profile image
John Woodruff

Thanks! :D Also good noticing! Looks like the key changed since I posted the original article to Medium, I'll update it to reflect that!

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
 
bgadrian profile image
Adrian B.G.

WSL is a good start, but that's about it. I wasted a few days to make a real setup for a real project and it doesn't work. it lacks some basic features like file watcher. I had many issues with it, google searched resulted in "WSL doesn't support this ...yet" or this library/framework doesn't support WSL yet. I'll give it a try again, maybe, in a few years.
Also running the IDE in windows and the file system being Linux sounds like asking for trouble.

Collapse
 
johnbwoodruff profile image
John Woodruff

I've found that the last Creators Update fixed a vast majority of the issues I had with WSL previously. With regards to your file watching support, looks like this is supported according to this blog post by Rich Turner.

As for your last comment, you're absolutely right, if you try to modify files in the linux filesystem with Windows programs, you're gonna have issues. Hence the Do not change Linux files using Windows apps and tools post by Rich, with a lot of red and bold text. ;) Personally, I have my files reside in a project folder on my C:// drive and symlink it to my home folder in WSL. That way it's easy to access, but I don't mess stuff up.

Thanks a bunch for your comments, I appreciate you reading my post! :)

Collapse
 
ruchinmunjal profile image
ruchinmunjal

Excellent article. Perhaps this little and very important tip about not changing Linux
Files from Windows should also go in the article?

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
 
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
 
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
 
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!

Collapse
 
gruutak profile image
Lucas Bertone

I loved the zsh and hyper tips. They will definitely be part of my setup from now on. Thank you very much

Collapse
 
johnbwoodruff profile image
John Woodruff

I'm so glad it was helpful! Thanks for reading!

Collapse
 
lase profile image
Matt Laser

Thanks for writing this up John. I've had the subsystem installed for over a year, but had no idea how to get it integrated with my tools. Super helpful!

Collapse
 
johnbwoodruff profile image
John Woodruff

Thanks so much, I'm glad it was helpful to you! :D

Collapse
 
jonasroessum profile image
Jonas Røssum

Really interesting article!

Collapse
 
johnbwoodruff profile image
John Woodruff

I appreciate the feedback! :)

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
 
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! :)