In my recent projects I was working with Angular and the Angular-CLI and I noticed that basic CLI commands like ng g c
, ng serve
, ng build
etc. take much more time in the wsl2 terminal (using ubuntu 20.04) than on the default powershell.
Any opinions or recommendations how to solve this problem?
If your project files are stored on the Windows filesystem and accessed/launched from WSL2, then yes, it's "normal" (or rather, known). The Microsoft documentation mention this behavior:
If you will be using your WSL Linux distribution to access project files on the Windows file system, [...] you will achieve faster performance across the OS files systems by using WSL 1.
I was experiencing the same slowliness with an Angular project using WSL2, and my files where on the Windows filesystem.
"Any opinions or recommendations how to solve this problem?"
In my case, copying the project files from the Windows filesystem to the WSL2 filesystem (e.g. $HOME/src
) fixed the performance issues. And in this configuration, WSL2 is effectively way faster than WSL1 :)
If you need to keep the source in a Windows folder (perhaps due to your development team workflow), then you may want to downgrade to WSL1, assuming you don't need any of WSL2's features. Keeping both WSL1 and WSL2 sessions around can make sense for this reason. You can backup/clone your existing session (see wsl --export
and wsl --import
) and set the WSL version for a distro with wsl --set-version
.
You might also consider sharing the Windows folder and mounting it via CIFS. Reports are that this is much faster (although not as fast as ext4). See this github issue and the suggested workaround from EvilVir on July 4th.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With