Guard won't load WDM

守給你的承諾、 提交于 2019-12-07 01:40:31

问题


I'm working through Michael Hartl's Rails tutorial which is excellent so far. I'm on the Advanced Setup Chapter, where he goes through configuring the Rails environment in a way conducive to TDD. I installed Guard, and it runs properly all the way through running the tests I have in my spec/ folder. But then, it spits out this error:

C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/listen-1.0.2/lib/listen/adapter.rb:195:in `require': cannot load such file -- wdm (LoadError)

I have wdm installed. I don't know why it can't load it.

It seems like Listen is having problems loading up WDM. It quits after it says "Guard is now watching..."

I haven't reproduced the rest of the stack trace for obvious reasons. I installed Rails using the latest Rails Installer. What's going on here? Do I need to worry about this? It appears to work at least partially...


回答1:


So here's what happened. By default, on Windows, Listen is supposed to use polling to check for filesystem changes. For some reason it was trying to use WDM. So, I had to had this to my Gemfile:

require 'rbconfig'
gem 'wdm', '>= 0.1.0' if RbConfig::CONFIG['target_os'] =~ /mswin|mingw/i

Maybe Guard makes Listen try to use WDM?




回答2:


Can't find where I got this recommendation from, but I was given the following for running guard across windows and linux:

gem 'rb-inotify', github: 'nex3/rb-inotify', platforms: :ruby, require: false
gem 'wdm', platforms: :mingw, require: false

The false's make it so the gems are only attempted to be loaded when running on that platform. Your windows environment may need mswin instead of mingw, depending on which ruby install you're using.




回答3:


Like said Binary Phile If you use rails in both windows and unix-like, you should use this in your Gemfile :

gem 'wdm','>= 0.1.0', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

it works fine and it's readable.



来源:https://stackoverflow.com/questions/16232960/guard-wont-load-wdm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!