deno icon indicating copy to clipboard operation
deno copied to clipboard

Deno.watchFs is not working in WSL environment

Open aaronwlee opened this issue 5 years ago • 8 comments

Deno.watchFs is not working in WSL(Ubuntu 18.04 LTS Bionic) environment. Literally, there are no event messages after changing any files.

aaronwlee avatar Aug 06 '20 01:08 aaronwlee

@aaronwlee please specify which version of Windows you are using, as it didn't always have support for these events (see https://devblogs.microsoft.com/commandline/wsl-adds-inotify-filesystem-change-notification-support/ )

Spoonbender avatar Aug 06 '20 05:08 Spoonbender

@Spoonbender I'm using Windows 10 19041.388 OS build and using wsl2.

what I'm claiming that it was working with the previous version.

aaronwlee avatar Aug 06 '20 06:08 aaronwlee

Probably related: https://github.com/notify-rs/notify/issues/254

I believe that problem affects deno run --watch too.

Running Deno inside Docker on Windows with WSL2 enabled, deno run --watch never detects any file changes even if I enter the container and change the file from inside the container (Alpine Linux in my case). If I change my Docker settings not to use WSL2, it works perfectly.

Leokuma avatar Jan 26 '21 00:01 Leokuma

same problem here 02/june/2022

BMogetta avatar Jun 02 '22 04:06 BMogetta

Same here:

  • Win 10 x64 build 19044.1766
  • WSL2; Ubuntu

Inside WSL2, touching a watched file reliably triggers watchFs, whereas inside Windows, saving a file stored on a Windows/NTFS drive that is mounted into WSL (e.g. as /mnt/g/somefile.js) never triggers watchFs.

twome avatar Jul 13 '22 05:07 twome

saving a file stored on a Windows/NTFS drive that is mounted into WSL (e.g. as /mnt/g/somefile.js) never triggers watchFs

This won't work* as long as you don't want to add a workaround by either switching to a polling-based change detection, through some sort of flag, or detecting WSL2 and then using the workaround. Notify simply won't receive file-events for windows-owned files inside WSL2.

*or wait for WSL2 to maybe fix that problem

0xpr03 avatar Sep 04 '22 23:09 0xpr03

@0xpr03 yeah I assumed as much. watchFs should be changed to detect WSL (might be good to do this earlier/higher up within Deno anyway, setting a user-visible flag) & then either (a) give an error message explaining this issue, or (b) fall back to polling. The silent failure's no bueno.

twome avatar Sep 10 '22 15:09 twome

I'm thinking about adding some runtime-detection based fallback to notify. This could also contain a WSL detection. But truth be told: If you want "performance", don't use the pollwatcher, if you want full compatibility, use it. So either way it is a trade-off.

0xpr03 avatar Sep 10 '22 16:09 0xpr03

You can use WSL 1 as a workaround for this issue

Kyiro avatar Jan 18 '23 16:01 Kyiro