Vagrant, shared folder: take advantage of inotify over NFS Vagrant, shared folder: take advantage of inotify over NFS docker docker

Vagrant, shared folder: take advantage of inotify over NFS


Unfortunately, inotify cannot work on NFS. inotify works by hooking itself in the VFS (virtual filesystem) layer, in the kernel. Whenever a modification happens, inotify knows about it, because the modification happens on the same machine, therefore in the same kernel — which makes the whole thing possible.

With NFS, modifications happen on the server, and notifications are expected on the client. But the NFS doesn't notify the clients when a change is made. Otherwise, it wouldn't scale. NFS has been designed (and operated) to have thousands of clients on a single server. Imagine if you do a tiny change, and the server has to push it to all clients!

Of course, you could say "hey, there should be a subscription mechanism in the NFS protocol, so that clients can tell the server that they want to know about changes happening in a specific location". Well, NFS was designed 30 years ago, so forgive them for not including this subscription/notification system :-)

I'm not familiar with Assetic, but maybe you could have a custom script to watch for changes manually, and re-compile assets each time you detect a change. Just walk through the directory containing the source for the assets, keep track of the mtime of each file in an associative array, and each time you detect a new file (or a new mtime), recompile. Boom!

See also this other SO question about inotify and NFS.


Here is a plugin which aim to solve this: https://github.com/mhallin/vagrant-notify-forwarder

Just install it and reload your boxes to have inotify notifications forwarded to your guests machine:

vagrant plugin install vagrant-notify-forwarder


You might be interested in this tool called Guard it listens to the file changes made on host OS, and then on Guest it pulls and update those. This worked for me, and now my assets are updated almost instantaneously.

https://serverfault.com/questions/453826/vagrant-shared-folder-and-file-change-events