watcher
watcher copied to clipboard
Linux: folders created via `mkdir -p` not watched recursively
Originally reported as https://github.com/microsoft/vscode/issues/142694
Steps:
- setup parcel watcher to watch on an empty folder
- execute
touch something
in that folder and verify you see a file event - execute
mkdir -p 1/2/3/4/5
and verify you get an event for the folder1
- execute
touch 1/2/3/4/5/something
- => 🐛 no event is fired
I have debugged this down to here:
https://github.com/parcel-bundler/watcher/blob/caf372c41abff401a60dde698891631e3387ee77/src/linux/InotifyBackend.cc#L149
inotify
seems to fire an event only for the first folder created (1
) and parcel watcher rightfully starts to watch 1
. However, since watchDir
itself is not recursive, the child folders are not getting watched.
I'm the reporter on https://github.com/microsoft/vscode/issues/142694. Just to be clear, this issue manifests itself as any change made to a deeply-nested file not being reflected in VSCode. The mkdir -p
demo was just a simple case. I'm seeing this in real projects with deeply-nested structures, most of which were created from within VSCode itself. My last comment on https://github.com/microsoft/vscode/issues/142694 has a demo of this happening.
similar issuer encountered with rust analyzer not being able to detect file changes. setting up watcher in rust analyzer instead seems to work maybe taking a look at what they are doing might help
https://github.com/rust-lang/rust-analyzer/issues/15603#issue-1894362378
Reproduce steps:
- create an empty project, with a module file like tmp.rs
- in root file(main.rs or lib.rs), write
mod tmp
;- open project with VSCode, no error
- in terminal, create another module, like
cp ./tmp.rs ./tmp2.rs
- in root file, write
mod tmp2
;- You would find it reports an error
unresolved module, can't find module file: tmp2.rs or...
Open the file tmp2.rs in VSCode would load the module.
And I found that
- RA does respect change/deletion from other tools
- once we opened tmp2.rs file once, then RA respects creation with steps 4-6 after we delete tmp2.rs
Maybe this is a bug of VSCode? Not sure...