adrienkohlbecker/vagrant-fsnotify

Polling for changes

Closed this issue · 5 comments

vagrant-fsnotify is using 99% of my CPU, is this supposed to happen?

Info
I'm using OSX El Capitan Version 10.11.5

When I run vagrant fsnotify I receive the following output:

rb-fsevent > 0.9.4 no longer supports OS X 10.6 through 10.8.

Please add the following to your Gemfile to avoid polling for changes:
  require 'rbconfig'
  if RbConfig::CONFIG['target_os'] =~ /darwin(1[0-3])/i
    gem 'rb-fsevent', '<= 0.9.4'
  end
[Listen warning]:
  Listen will be polling for changes.Learn more at https://github.com/guard/listen#listen-adapters.
rb-fsevent > 0.9.4 no longer supports OS X 10.6 through 10.8.

Please add the following to your Gemfile to avoid polling for changes:
  require 'rbconfig'
  if RbConfig::CONFIG['target_os'] =~ /darwin(1[0-3])/i
    gem 'rb-fsevent', '<= 0.9.4'
  end

I experienced this problem with OS X 10.11.5 + Vagrant 1.8.4 + vagrant-fsnotify 0.3.0. After reading this issue, I installed Vagrant from source and it solved the issue.

Vagrant 1.8.4 includes listen 3.0.8, which is the cause of the issue. Apparently Vagrant 1.8.1 does not experience this issue, so I guess this is the highest current official version of Vagrant if you don't want to install from source. Current Vagrant master includes listen 3.1.5.

I hadn't installed Vagrant from source before, and it was mostly painless. Some things I noticed:

  • The bundler version on this page doesn't match the required version (1.12.5). Just do a gem update bundler if you have an older version.
  • The vagrant binary path on this page (/usr/bin/local) didn't match where my Vagrant 1.8.4 binary (symlink) was (/usr/bin). I changed the symlink location on the last line to match my install: ln -sf /path/to/vagrant/exec/vagrant /usr/bin/vagrant

How to install plugins with a source install of Vagrant:

1 - Edit the Gemfile inside the directory where you cloned the Vagrant source. Add a :plugins group with the plugins you want:

group :plugins do
  gem 'vagrant-fsnotify'
end

2 - Run bundle install inside the Vagrant source directory to install the plugin.

After following those steps, the plugin(s) will be autoloaded and you can use them as usual, i.e. vagrant fsnotify. I'm using this setup now for Elixir/Phoenix development with hot code reloading and it's working perfectly with negligible CPU usage. Hope this helps!

Thanks @mekuls for reporting this issue and @PGrunwald for finding a workaround.
It seems there is not much I can do on my end, you will have to install from source while waiting for 1.8.5 to come out, or use 1.8.1.

I will add a warning for those running a version of vagrant which has the issue.
I'll keep this issue open until 1.8.5 comes out

danez commented

Is it working for you guys with 1.8.5? I still have the same problem.

I was having the same problem and followed @PGrunwald's instructions. I was still having a problem and found I was running vagrant from a script installed by an old vagrant gem that was in my ~/.rvm/gems/ruby-2.2.4/bin directory (found using which vagrant). The gem had been uninstalled, but it didn't remove that file. After removing that file I verified the proper version of vagrant was running and fsnotify was no longer polling.

Going to close this for inactivity, feel free to comment or re-open if still current