Open Mimerme opened 4 years ago
Hi, I ran across this as well, except while using notify 4.0.15 and I didn't receive any events.
I ran the same application in the following three environments (each environment updated to the latest version):
Windows 10 Pro Workstation WSL 2 PopOS! 20.10 (in hyper-v)
using rust 1.48
Windows and PopOS! the simple application behaves as expected, though with differing raw events and in WSL the application does not receive any notifications.
I'm seeing behavior in cargo-watch
and watchexec
which might be explained by this bug and, if it's related, a potential clue.
cargo-watch
7.5.0watchexec
1.14.0As expected, modifying a watched file from within the WSL2 terminal, e.g. using echo -e "\n" >> src/lib.rs
or editing in the term-based emacs, triggers the specified command. However, modifying the same file from VS Code using remote WSL doesn't trigger the command.
EDIT: For anyone else seeing this behavior, I also discovered running cargo-watch
from VS Code's Terminal feature successfully triggers the specified command.
I confirmed this issue occurs in WSL2 in windows build Version 10.0.19043.1110. I don't run insider builds, so I don't know if a more recent version of WSL/Win10 fixes it. It worked with WSL 1.
When running in WSL, the windows implementation of notify-rs
is not actually used. The inotify watcher is used. The mio poll function is simply not returning, so maybe inotify is not actually producing anything. I guess its an issue with WSL2.
A workaround is to use the PollWatcher, which does work, with a performance hit:
PollWatcher::with_delay(Arc::new(Mutex::new(event_fn)), Duration::from_millis(500))
Yeah I also guess it's an issue with how WSL2 works and is not reporting any changes to the linux kernel for the virtualized file system.
System details
What you did (as detailed as you can)
Running this code and setting
file_watch
to a specific text file and then editing it in vim and saving it only prints the first 3 events, but nothing after that.What you expected
Editing it in vim and saving it only prints the first 3 events for the first save, but nothing after that. I expected that making additional edits and saving them would print more events, but this did not happen.
What happened
Only the first 3 events when editing with vim are printed.
Additional Notes
When setting
file_watch
to the text file's directory, the program actually prints that events where thepaths
attribute contains the specific file when writing multiple times with vim. I think there's an issue in the library with filtering out specific events.