In this post, I cover some first impressions from my experience installing and running WSL2 (Windows Subsystem for Linux) in my dev workflow.
I haven’t done any exhaustive, scientific, or precise tests by any means. What I have found though is that WSL is about 5 times faster for everyday web development tasks like npm or yarn.
Also, hot reloading and working with create-react-app or the vue-cli is faster!
Read on for installation, getting started, gotchas, and specific timing on
What does WSL 2 bring?
This is the process I went through and the surprises I encountered while installing.
Installing WSL2 on Windows 10
Microsoft now has stable documentation on how to install WSL and update to WSL2.
To get up and running, follow the guide above through to the point where you set up a new linux distribution.
Checking if the Install Worked
The following command will show us what distros we have installed and what version they are on:
- wsl --list --verbose
- # or shorthand
- wsl -l -v
If you already had Ubuntu installed on WSL 1, you may have to completely uninstall and reinstall it.
If your computer is having trouble running the update command (like my computer), then you may want to completely uninstall and reinstall your distro.
I went into the Windows settings under Apps > Apps and Features and uninstalled Ubuntu:
Then I made sure that the default version I wanted for all new installs was version 2:
- wsl --set-default-version 2
Now we can go into the Windows Store to install it:
Once we’re installed, then we can check to be sure that version 2 was installed. Open up Powershell and run:
You can open up Windows Terminal and use the Ubuntu dropdown:
Alternatively you can open up either
Powershell and run:
- # open up windows subsystem for linux
Gotchas with WSL 2
Speed when transferring between file systems is a little slow right now. That’s not a worry for me since I never transferred. I worked solely inside of my Windows files which were mounted into the Linux system.
Here’s a guide on User Experience changes from WSL 1 to WSL 2. The two big gotchas are:
- Move your files into the Linux file system instead of your Windows system
- You will need to access localhost apps like
[localhost:3000](http://localhost:3000) via an IP address like
Move all files into Linux
To take advantage of all the new speed improvements in WSL 2, our files will need to be moved into the Linux filesystem.
The best way to figure out where to move your files is to find the home directory in Linux, then open it in Windows explorer. Run the following:
- # find the home folder
- cd ~
- # open up windows explorer for this folder
- explorer.exe .
Notice the path as a Network path:
We can now move our files from our Windows folders into this new networked folder. We’ll be able to access it from our WSL and interact with it as if it were still in the same Windows files.
For instance, we can install Node using a tool like n and then run
npm start to run a local server for let’s say a React app.
Network Isn’t localhost Yet
When we create an app using create-react-app or the vue-cli, we will usually run a command like
yarn start or
yarn serve to run a local server.
Normally we would be able to check on our application right in our browser using
[localhost:3000](http://localhost:3000) for React or
[localhost:8080](http://localhost:8080) for Vue.
In the early stages of WSL 2, we can’t use localhost. We need to use an IP since Linux is inside a VM.
To access your application currently, we will use an IP.
192.168.28.2:3000. We’ll use that to access our application:
A Quick Comparison and Speed Test
This entire exercise was to get a setup that was faster than the previous one. Let’s see if this setup is any faster!
I don’t have anything too scientific. I’ll go back and run more tests, but I was frustrated how long a new React app took WSL 1 to make.
For now, our test will be to run npx create-react-app my-new-app.
We’ll be comparing the following machines. I know this isn’t scientific at all. I wish I had more computers with similar setups. I wish I had done these speed tests before I upgraded to WSL 2. Oh well. We have what we have!
- My desktop machine (super powerful, more than the laptops for sure)
- Surface Book 2 15" i7
- MacBook Pro 15" 2015
- npx create-react-app my-new-app
Here are the numbers I got from running the test a few times on each platform.
- Surface Book 2 WSL 1: 257 seconds
- Surface Book 2 WSL 2: 52 seconds
- 2015 MacBook Pro: 45 seconds
- 2018 MacBook Pro: 38 seconds
While still not as fast as the latest MacBook Pro, WSL 2 has made significant improvements over WSL 1.
We’ll keep getting updates and I’ll keep testing to see if performance is improving. I would love to get to a point where WSL 2 on Windows could be as fast as a 2018 MacBook Pro.
I love both Windows and Mac platforms and with WSL 2, my tools on both platforms has gotten even closer: