watcher icon indicating copy to clipboard operation
watcher copied to clipboard

Linux: folders created via `mkdir -p` not watched recursively

Open bpasero opened this issue 3 years ago • 2 comments

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 folder 1
  • 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.

bpasero avatar Feb 11 '22 11:02 bpasero

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.

grahamb avatar Feb 11 '22 19:02 grahamb

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:

  1. create an empty project, with a module file like tmp.rs
  2. in root file(main.rs or lib.rs), write mod tmp;
  3. open project with VSCode, no error
  4. in terminal, create another module, like cp ./tmp.rs ./tmp2.rs
  5. in root file, write mod tmp2;
  6. 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...

king-11 avatar Sep 15 '23 12:09 king-11