11

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?

Cowas
  • 328
  • 2
  • 12
  • 1
    I just upgraded to WSL2 yesterday and I'm experiencing this right now :( – kyw Jul 29 '20 at 03:28
  • Hi, could you elaborate a bit more on what you mean with "much more time"? I'm having issues with running `ng serve` (even with `--verbose=true`) as it seems to hang for about five minutes before it continues. It used to work much faster (i.e. a couple of seconds). – Gorgsenegger Nov 26 '20 at 09:59

1 Answers1

15

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?"

  1. 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 :)

  2. 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.

  3. 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.

NotTheDr01ds
  • 15,620
  • 5
  • 44
  • 70
Tazaf
  • 350
  • 5
  • 15
  • 1
    Tazaf, if you'd like to incorporate the additional items from my answer into yours, I don't mind (and I can then delete my answer). I wouldn't have seen this 20-day old question if you hadn't generated some new activity on it. – NotTheDr01ds Aug 17 '20 at 21:06
  • 1
    @NotTheDr01ds That's very fair of you. I could update my answer to add the details, but I'd feel better if you were to submit and edit of my answer, so that you're at least somewhat credited for the additionnal information. – Tazaf Aug 19 '20 at 08:10
  • 1
    Ah, right - Fairly new to answering, so didn't realize that was an option. I'll do that now. Thanks! – NotTheDr01ds Aug 19 '20 at 15:01