简体   繁体   English

Guard不会加载WDM

[英]Guard won't load WDM

I'm working through Michael Hartl's Rails tutorial which is excellent so far. 我正在研究Michael Hartl的Rails教程,这个教程到目前为止都非常出色。 I'm on the Advanced Setup Chapter, where he goes through configuring the Rails environment in a way conducive to TDD. 我在高级设置章节中,他以有利于TDD的方式配置Rails环境。 I installed Guard, and it runs properly all the way through running the tests I have in my spec/ folder. 我安装了Guard,它通过运行我的spec /文件夹中的测试一直运行正常。 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. 我安装了wdm。 I don't know why it can't load it. 我不知道为什么它无法加载它。

It seems like Listen is having problems loading up WDM. 似乎Listen在加载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. 我使用最新的Rails安装程序安装了Rails。 What's going on here? 这里发生了什么? Do I need to worry about this? 我需要担心吗? It appears to work at least partially... 它似乎至少部分工作......

So here's what happened. 所以这就是发生的事情。 By default, on Windows, Listen is supposed to use polling to check for filesystem changes. 默认情况下,在Windows上,Listen应该使用轮询来检查文件系统更改。 For some reason it was trying to use WDM. 出于某种原因,它试图使用WDM。 So, I had to had this to my Gemfile: 所以,我必须把它放到我的Gemfile中:

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

Maybe Guard makes Listen try to use WDM? 也许Guard会让Listen尝试使用WDM?

Can't find where I got this recommendation from, but I was given the following for running guard across windows and linux: 找不到我推荐的地方,但我在Windows和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. 您的Windows环境可能需要mswin而不是mingw ,具体取决于您使用的ruby安装。

Like said Binary Phile If you use rails in both windows and unix-like, you should use this in your Gemfile : 就像说Binary Phile一样如果你在windows和unix-like中使用rails,你应该在你的Gemfile中使用它:

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

it works fine and it's readable. 它工作正常,可读。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM