Project Management in WSL: How to use wsl for development?

Devanshu Tiwari
3 min readJan 19, 2021

If you have decided to use WSL in Windows for your development work, you will most probably face one common dilemma. Should you save your project files in Windows file system which is NTFS or should you use the ext file-system of Linux? The answer is short and interesting. 😛

WSL — According to Microsoft :
The Windows Subsystem for Linux lets developers run a GNU/Linux environment — including most command-line tools, utilities, and applications — directly on Windows, unmodified, without the overhead of a traditional virtual machine or dualboot setup.

Method 1: Using Linux file system to access files on Windows:
Let’s say you decide to store all your projects in C drive. For doing that using terminal, you have to change directories to reach C drive using cd command. As the windows file system is mounted in the /mnt folder in WSL. From here, we can access C drive by changing directory /mnt/c/ . Now creating a projects folder using mkdir here will result in a projects folder being created in our Windows C drive. We can create a symlink to our projects folder that we just created. So, everytime we create a new project we only have to change directory to the symlink that we created and start developing our projects from that location. But wait!, this method is not optimal, as you will face problems when you use git, or try to create or delete new files since the windows drives are sometimes owned by root. Also the file permissions, that are used in ext file system, are not applicable to Windows NTFS.
Even if it works, WSL performs poorly, when it has to access the native file system of Windows.(It is also one of the limitations of using WSL which i believe, they have improved in WSL2). Hence, we follow method 2.

Method 2: Using Windows file system to access files on Linux.
Now, we use the default location of files that WSL provides. Accessing files in this way is fast and secure. All files are stored /home/@username in WSL. We can start working on our projects from there just like we do on a Linux Machine. But there’s one small problem, the Linux environment that is provided by WSL has a separate space for running it’s ext file system. This memory space is located on a mapped network drive on Windows which is not easily accessible using our GUI of Windows. And although, if you try harder, you can locate those files, but modifying them from Windows directly can result in unexpected errors or system-crash.
So, what if you want to copy some media files in your projects folder from the downloads folder in Windows? Or what if you want to open a html file from your projects folder in WSL? Here’s the solution :Remote-WSL extension in VSCode comes to our rescue. Whenever you want to access any particular file on WSL just right-click on the file in file-explorer pane of VSCode and click on “Reveal in Explorer”, which then opens the location of file on the mapped network drive.
Just make sure, not to delete the system files or make unnecessary changes other than opening or copying data.

I have been using WSL for web-development for some time now, and it feels just like working on a pure Linux OS. Without all the hassle of creating a dual-boot system or using a Virtual Machine we get best of both systems. Comfort of Windows and command-line of Linux. 😉

Have a great and adventurous day!

--

--

Devanshu Tiwari

If you can’t explain it simply, you don’t understand it well enough