bensu / doo

doo is a library and lein plugin to run cljs.test on different js environments.
Eclipse Public License 1.0
324 stars 63 forks source link

watch-mode auto not working in Vagrant vm #156

Open Sgoettschkes opened 6 years ago

Sgoettschkes commented 6 years ago

I'm using Vagrant (a wrapper for virtual machines) for my projects which means each project lives inside a virtual machine. The source code is on my host machine and a mount is created inside the vm to have the code available there too.

Running lein doo node test once inside the vm works as expected and running lein doo node test works as well (the correct tests are executed and the watcher is started), but file changes are never picked up.

Watching for file changes is always a problem with mounted folders. For figwheel, I have to use the :hawk-options {:watcher :polling} setting, otherwise it doesn't pick up any changes either. lein-test-refresh works out of the box.

miikka commented 6 years ago

Doo uses ClojureScript's built-in watching functionality, which is implemented using java.nio.file.WatchService (the same as Figwheel's watch default settings). WatchService looks at the file system events, but they do not get forwarded from the host to the Vagrant guest, which causes the problems. To fix this, I see a couple of possible approaches:

  1. convince ClojureScript to add support for alternative ways of watching,
  2. re-implement watching in Doo (maybe using hawk to make it configurable the same way as Figwheel),
  3. somehow piggyback on Figwheel's watcher or on cljsbuild's auto mode?

(For the record: lein-test-refresh uses clojure.tools.namespace's change tracking.)


As a workaround, you might want to check out some of the Vagrant plugins for forwarding file system events: vagrant-notify-forwarder, vagrant-fsnotify. Haven't tried any of them myself, though.

Sgoettschkes commented 6 years ago

Thanks for the detailed analysis, miikka. I am using a Vagrant plugin right now and it works well. As you pointed out, this is only a workaround because most of the notifier plugins to not work on all platforms, are error-prone and it's an additional setup step which might get lost.

I appreciate your list of possible approaches and would consider working towards the one you think would be most feasible.