So, I read about this new feature on Twitter not sure who made that tweet or was it a sponsored one. But I saw that Microsoft has release Windows Subsystem for Linux (WSL) version 2. Now, I was not even aware version 1 existed (I guess I was too outdated in the windows world) but this news caught my attention. Windows and Linux in the same tweet. Well, that’s interesting I thought and started reading about the feature.
So, what is this new WSL?
Microsoft’s WSL is a way for you to install a Linux environment on your Windows machine. So, now many would say – well what’s so new about it. We have VM Ware which allows us to do that. We can even use the open source version Virtual Box and install a Linux OS inside a Windows machine. However, the interesting thing about WSL is that the filesystem is integrated with your Windows system.
By that, I mean you can have your Node or PHP project inside a Linux system. And, when you run “code .” from inside your Linux console, the folder will open up inside Visual Studio Code. Or, even right click and open that folder inside PHP Storm of VS Code (see screenshot below)
Yes, it’s real. I do a lot of PHP development and most of it is using Laravel. And, I never liked the idea of having WAMP or XAMP to control my LAMP stack. And, that was one big reason I never used Windows as my primary OS for development. However, with this I get the best of both worlds. I am able to execute my code from inside the Ubuntu environment staying within a Windows environment. Using the Windows terminal, I am able to run all Linux commands required inside any unix based system, upgrading of PHP and other stuff can be done using the APT package manager.
The port mapping is seamless, so when you go to http://localhost, you will get the familiar Apache welcome page. If you run “php artisan server” inside Linux, you will be able to see the Laravel welcome page on http://localhost:8000 and that goes true for all other services and ports.
Some issues that I have faced
However, there are some open issues which I am already aware of:
- The clock has some issue and hence, my mysql service doesn’t start automatically. It showed some error during installation (however everything works fine). Just, that when I start my machine, I go and run sudo service start mysql. (Looking for a fix for the same as of now)
- The file system on Windows and Linux are different. So, if you reference any file from Windows inside Linux, folder permissions can be a problem. Like, I have a lot of ssh .pem files which are stored inside my Dropbox folder so that I don’t loose them. Now, if I create a symlink of the Dropbox folder from the Windows file system into the Linux machine, the “File is too open” permission issue comes up. And, you can’t fix that.
Other than that, I am overall very happy. My desktop (which is my primary development machine) is running on Windows 10 instead of Linux and I think I will continue to use it because things can only get better from here. And this does mean, I may not have to spend a huge amount on a new Mac Book Pro as my primary development environment and upgrades will not be so costly.
Tell me what do you think about this new feature. You can get in touch with me on my twitter handle @amitavroy7