Using ember build --watch on vagrant box - error


I use ember build -watch to build our app because we host the /dist in our own server.

I’ve just set up a vagrant box so I can start getting the other guys to dev on the app but after installing everything and trying it out I get the following:

watch ENOSPC
Error: watch ENOSPC
    at errnoException (fs.js:1024:11)
    at FSWatcher.start (fs.js:1056:11)
    at (fs.js:1081:11)
    at Watcher.watchdir (/vagrant/sonatribe-ui/node_modules/ember-cli/node_modules/broccoli-sane-watcher/node_modules/sane/index.js:187:20)
    at new Watcher (/vagrant/sonatribe-ui/node_modules/ember-cli/node_modules/broccoli-sane-watcher/node_modules/sane/index.js:66:10)
    at EventEmitter.Watcher_addWatchDir [as addWatchDir] (/vagrant/sonatribe-ui/node_modules/ember-cli/node_modules/broccoli-sane-watcher/index.js:69:17)
    at /vagrant/sonatribe-ui/node_modules/ember-cli/node_modules/broccoli/lib/builder.js:66:35
    at $$$internal$$tryCatch (/vagrant/sonatribe-ui/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:470:16)
    at $$$internal$$invokeCallback (/vagrant/sonatribe-ui/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:482:17)
    at /vagrant/sonatribe-ui/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:1066:13

Has anyone got this working (even ember serve uses the watch command at some point) on a vagrant box? I’m guessing it’s because vagrant is already syncing the /vagrant folder?

I’ve seen a similar error that was resolved by increasing my ulimit and increasing fs.inotify.max_user_watches in /etc/sysctl.conf.

This had to do with the number of file handlers the OS allows opened by default. These are creates so that ember-cli is able to watch for file changes.

I haven’t been able to get file system watching to work in Vagrant without using the --watcher polling argument to ember serve (which is kinda suboptimal because it spikes the CPU and chews up battery).

It seems to work out of the box for me otherwise, though.

My problem apart from the --watcher polling is also the quite bad performance. I have tried to use ember-cli within a docker container, and rebuilds now take 3s instead of 800ms-1s. I do wonder if it would be possible to get the performance on a level that is comparable.

Which synced folder mechanism are you using? I’ve found that nfs is a lot faster than the default.

I gave up on using /vagrant and just pulled the code into the box as we are using it with a desktop (we have compiled code in the backend so this seemed the best way forward) - works like a charm

I was struggling with getting watchman to work (file system events aren’t triggered in regular virtual box shared folders), then stumbled across this amazing project: . Create a lcoal box using docker-machine with many improvements over the standard virtualbox, including nfs shares.