-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unable to watch file edits by vim #247
Comments
I see the same behavior with 5.0.0-pre.2 on Linux Mint 19.3 when watching a single file. If I watch a directory, I continue to see updates. Edit: This also happens on 4.0.13. |
The same behavior with When I use stdout and filepipe to update the file, I do get messages: echo hello world >> PATH_TO_TEXT_FILE
|
I think this is related to how vim handles writing. Temp file gets created and it is moved to the original file when writing is issued. |
This is indeed because of how vim handles file writing. In particular, the responsible vim option is
|
I edited the title in hopes of making it easier to find. @haoyu0015 are there still questions, or can this be closed ? |
@0xpr03 I know the root cause of this issue , but could this issue be fixed in this crate ? I still need it to watch a single file change which edited by vim |
@haoyu0015 The way to track a file across rename tricks like vim does, is to watch the directory that contains the file. Then, you will still get a "remove" event first, but then you will get a "create" event for the new file as well. In your application code, you can observe these two and conclude that something like this happened. This should probably not be added in the low-level API that I don't know if an existing crate already implements this. |
Another problem is how different Windows/Linux/MacOS report events about files. IIRC this can also be a big problem. If notify-rs would just try to abstract this for one of them, many issues could be fixed or features added in a much easier way/time. I'm not saying I'm against it, I just know how fragile this whole thing can be. |
I would definitely be a proponent of a crate that abstracts over all this platform-specific mess. It might even need to be |
Never mind. If you are not going to add something to fix it, you can close this issue. But if plan to add some extra abstraction layer to solved it, may keep this issue and let me know if done. Thank you |
@haoyu0015 you can add these lines to your
|
Old thread, but it helped me out ❤️ I'll describe my problem for the search engines, in case there's more like me. I had a notify-based build daemon watching some files I was editing in Neovim on Linux. The odd thing is that the first edit was always detected, but the second and all subsequent edits weren't. With @oren0e's tip I added to my editor config: vim.opt.backup = false
vim.opt.writebackup = false and everything worked as normal 🎉 |
System details
OS/Platform name and version: ubuntu 18.04
Rust version (if building from source):
rustc --version
: 1.40.0Notify version (or commit hash if building from git): the newest one(5.0.0-pre.2)
If you're coming from a project that makes use of Notify, what it is, and a link to the downstream issue if there is one:
Filesystem type and options:
On Linux: Kernel version: Linux wlan16 4.15.0-72-generic Watch only new directories in the monitor example #81-Ubuntu SMP Tue Nov 26 12:20:02 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
On Windows: version and if you're running under Windows, Cygwin (unsupported), Linux Subsystem:
If you're running as a privileged user (root, System): yeah, is root.
If you're running in a container, details on the runtime and overlay:
If you're running in a VM, details on the hypervisor:
What I did
I use the example in the git repository and want to hot watch a single file changed. I create a project and the src code is the same as the example:
https://github.com/notify-rs/notify/blob/main/examples/monitor_raw.rs
I create a singe file in the path "/root/watcher/aaa", then I run the process with argument "/root/watcher/aaa", then I use vim to write "www" into the file "aaa" twice times, only the first time have notfication, and the second times was ignored.
The log of first times I changed the file like that:
watching /root/watcher/aaa
changed: Event { kind: Modify(Name(From)), paths: ["/root/watcher/aaa"], attr:tracker: None, attr:flag: None, attr:info: None, attr:source: None }
changed: Event { kind: Modify(Metadata(Any)), paths: ["/root/watcher/aaa"], attr:tracker: None, attr:flag: None, attr:info: None, attr:source: None }
changed: Event { kind: Remove(File), paths: ["/root/watcher/aaa"], attr:tracker: None, attr:flag: None, attr:info: None, attr:source: None }
The second times I changed the file no any log
The text was updated successfully, but these errors were encountered: