Mike MJ Harris

My attempt(s) at using Linux on Windows

Share

Microsoft are increasingly trying to make their products and tools appeal to a wider range of developers. Recently they released WSL - Windows Subsystem for Linux. This allows users to run a Linux like environment on Windows with little overhead. But how does it work in practice? What's it like to setup and how does it compare to a native Linux environment?

A brief history of my computers

How useful or interested you may find WSL will probably depend on what computers you are used to. For the first ten years of my working life (~2002 - 2013) I worked in finance and worked only with Windows - (primarily for Excel). With much horror I had to switch to Apple when changing careers to coding in 2014 - obviously I then fell in love with Macs and couldn't imagine anything else. In my first weeks at the Royal Academy of Arts in 2017 an unfortunate incident with an automatic tap and an open laptop bag meant I ruined my smart new computer - there was a spare Dell laptop so with the help of a team member (who was a Linux user) I setup Ubuntu and have been a dedicated desktop Linux user since.

Pic from previous post about coding with a chromebook - showing 2013 Mac Air and the chromebook

My home laptops have followed a similar curve - for the majority of the last few years I've mainly been using a Macbook Air I got myself in 2013. I've had a few other gadgets: I've written in the past about coding on a chrome book; last year I got a MS Surface Go.

I was due an upgrade on the old home Mac Air. At work I've been very happy with Dell XPS 13 developer edition with Ubuntu already setup. The refurbished Dell store however had an excellent deal on a Windows laptop - saving money (and saving the world?) I chose that and decided to set it up as a dual boot with Linux as well as using it as an opportunity to give WSL a proper go.

First go at WSL - 2020

As mentioned in 2020 I got a Surface Go. It's small and while not super powerful it has lots more beef that my chromebook. I wanted to try WSL on it so that I could have something to either code on locally or act as a dumb terminal to code in the cloud.

WSL was in its first version then and there were definitely a few issues - I can't remember all the details but here's the rough notes I made at the time about the problems I encountered: long/complex setup, fonts, icons, cursor spacing, gpg can't connect to agent, need to install apt repo, docker.

There were enough issues that my enthusiasm waned and the Surface Go ended up permanently attached to my exercise bike as a window into the virtual Zwift world.

Second go at WSL - 2021

In late 2021 I got my new laptop. First I setup dual boot, then ran my install scripts and fairly quickly I had my familiar Linux environment running - everything as I like it and no real issues.

Then I tried out Windows - WSL 2 had come out with the promise of quicker setup and better features. Initially though it didn't seem that much had changed since my first attempt - there were quite a few hoops to jump through: running Powershell commands, updating various settings and even a BIOS change.

Eventually I had Ubuntu 20 running in a window. The main difference to my first attempt was the amount of blog posts/stackoverflow answers to help one along.

Familiar environment

With Ubuntu running I ran the install scripts I'd just been using on the dual boot. Most things ran but was a bit disappointed to see that again some of the issues from WSL 1 were still present: problems with fonts/cursor/icons. I tried to fix some of these with limited success, moved onto other issues but then a day or two later found the solution. Switching from the default Windows Console Host to the new Windows Terminal meant that looks wise things were pretty much the same as on my native Linux setup!

WSL and the Windows environment

Most of my time is spent in the terminal. Things now looked similar to my dual boot Linux environment but a few key features were missing. The main one was integration with the system clipboard - something I use a lot in the terminal either editing code or piping data around. Quite a bit of investigation and learning how WSL is setup within the Windows environment meant resulted in these two commits in my config repo which solved my vim and terminal issues.

Windows Terminal - with Options to run Powershell, Ubuntu or Azure shell.

The power of Linux and Windows

In delving into these issues I started really appreciating the benefits of WSL. You can invoke windows commands in WSL and Linux commands in Powershell. They can run together in the fantastic Windows Terminal along with things such as Azure Shell or even other Linux versions. I had what felt like a proper first class Linux build but could rely on the quality of Windows for things like sound (an area that can be complicated with Linux) and also the ability to run Windows programs and potentially enticing me to dabble with a Windows coding environment. There seemed to be the best of both worlds available to me with lots of overlap.

Conclusion

At a number of points in the process I almost gave up on WSL - I had a perfectly good working Linux envoronment on the other half of the hard drive. Why was I going through this pain for something I thought would be inferior?

I'm glad I persisted - am really enjoying the setup. I've mainly been using it for a few small projects but will aim to stick with it for a few months and report back on how I get on as a main dev machine.

How you get on may depend on what you are used to using - I think any Linux or Windows users will see a lot of benefits from WSL. If you use Microsoft's VSCode then I'd anticipate you'd have much fewer issues getting things setup. If you are a dedicated Mac user then the hassle may not be worth it. Interestd to hear if anyone is using it as their main work dev environment and any cool features or setups you've found useful.