当我运行guard init时出现错误
app>guard init
14:56:14 - ERROR - Could not load 'guard/phpunit' or '~/.guard/templates/phpunit
' or find class Guard::Phpunit
保护文件已创建,但为空。它应该包含此代码
guard 'phpunit', :cli => 'colors' do
watch(%r{^.+Test.php$})
end
但是当我手动编辑文件以包含它并运行后卫时我得到了
app>guard
14:59:32 - ERROR - Could not load 'guard/phpunit' or find class Guard::Phpunit
14:59:32 - ERROR - C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb
:1637:in `raise_if_conflicts'
> [#] C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:746:in `acti
vate'
> [#] C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems.rb:212:in `rescue in try_acti
vate'
> [#] C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems.rb:209:in `try_activate'
> [#] C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `resc
ue in require'
> [#] C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `requ
ire'
> [#] C:/Ruby193/lib/ruby/gems/1.9.1/gems/guard-2.2.4/lib/guard/plugin_util.rb:1
00:in `plugin_class'
> [#] C:/Ruby193/lib/ruby/gems/1.9.1/gems/guard-2.2.4/lib/guard/plugin_util.rb:5
7:in `initialize_plugin'
> [#] C:/Ruby193/lib/ruby/gems/1.9.1/gems/guard-2.2.4/lib/guard.rb:167:in `add_p
lugin'
> [#] C:/Ruby193/lib/ruby/gems/1.9.1/gems/guard-2.2.4/lib/guard/dsl.rb:175:in `b
lock in guard'
> [#] C:/Ruby193/lib/ruby/gems/1.9.1/gems/guard-2.2.4/lib/guard/dsl.rb:173:in `e
ach'
> [#] C:/Ruby193/lib/ruby/gems/1.9.1/gems/guard-2.2.4/lib/guard/dsl.rb:173:in `g
uard'
> [#] C:/Users/Mark/Dropbox/www/trainercompare/app/Guardfile:4:in `_instance_eva
l_guardfile'
> [#] C:/Ruby193/lib/ruby/gems/1.9.1/gems/guard-2.2.4/lib/guard/guardfile/evalua
tor.rb:121:in `instance_eval'
> [#] C:/Ruby193/lib/ruby/gems/1.9.1/gems/guard-2.2.4/lib/guard/guardfile/evalua
tor.rb:121:in `_instance_eval_guardfile'
> [#] C:/Ruby193/lib/ruby/gems/1.9.1/gems/guard-2.2.4/lib/guard/guardfile/evalua
tor.rb:37:in `evaluate_guardfile'
> [#] C:/Ruby193/lib/ruby/gems/1.9.1/gems/guard-2.2.4/lib/guard/setuper.rb:144:i
n `evaluate_guardfile'
> [#] C:/Ruby193/lib/ruby/gems/1.9.1/gems/guard-2.2.4/lib/guard/setuper.rb:62:in
`setup'
> [#] C:/Ruby193/lib/ruby/gems/1.9.1/gems/guard-2.2.4/lib/guard/commander.rb:24:
in `start'
> [#] C:/Ruby193/lib/ruby/gems/1.9.1/gems/guard-2.2.4/lib/guard/cli.rb:96:in `st
art'
> [#] C:/Ruby193/lib/ruby/gems/1.9.1/gems/thor-0.18.1/lib/thor/command.rb:27:in
`run'
> [#] C:/Ruby193/lib/ruby/gems/1.9.1/gems/thor-0.18.1/lib/thor/invocation.rb:120
:in `invoke_command'
> [#] C:/Ruby193/lib/ruby/gems/1.9.1/gems/thor-0.18.1/lib/thor.rb:363:in `dispat
ch'
> [#] C:/Ruby193/lib/ruby/gems/1.9.1/gems/thor-0.18.1/lib/thor/base.rb:439:in `s
tart'
> [#] C:/Ruby193/lib/ruby/gems/1.9.1/gems/guard-2.2.4/bin/guard:6:in `<top (requ
ired)>'
> [#] C:/Ruby193/bin/guard:23:in `load'
> [#] C:/Ruby193/bin/guard:23:in `<main>'
14:59:32 - ERROR - Invalid Guardfile, original error is:
> [#] undefined method `superclass' for nil:NilClass
C:/Ruby193/lib/ruby/gems/1.9.1/gems/guard-2.2.4/lib/guard/plugin_util.rb:57:in `
initialize_plugin': undefined method `superclass' for nil:NilClass (NoMethodErro
r)
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/guard-2.2.4/lib/guard.rb:167:in
`add_plugin'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/guard-2.2.4/lib/guard/dsl.rb:17
5:in `block in guard'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/guard-2.2.4/lib/guard/dsl.rb:17
3:in `each'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/guard-2.2.4/lib/guard/dsl.rb:17
3:in `guard'
from C:/Users/Mark/Dropbox/www/trainercompare/app/Guardfile:4:in `_insta
nce_eval_guardfile'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/guard-2.2.4/lib/guard/guardfile
/evaluator.rb:121:in `instance_eval'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/guard-2.2.4/lib/guard/guardfile
/evaluator.rb:121:in `_instance_eval_guardfile'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/guard-2.2.4/lib/guard/guardfile
/evaluator.rb:37:in `evaluate_guardfile'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/guard-2.2.4/lib/guard/setuper.r
b:144:in `evaluate_guardfile'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/guard-2.2.4/lib/guard/setuper.r
b:62:in `setup'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/guard-2.2.4/lib/guard/commander
.rb:24:in `start'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/guard-2.2.4/lib/guard/cli.rb:96
:in `start'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/thor-0.18.1/lib/thor/command.rb
:27:in `run'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/thor-0.18.1/lib/thor/invocation
.rb:120:in `invoke_command'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/thor-0.18.1/lib/thor.rb:363:in
`dispatch'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/thor-0.18.1/lib/thor/base.rb:43
9:in `start'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/guard-2.2.4/bin/guard:6:in `<to
p (required)>'
from C:/Ruby193/bin/guard:23:in `load'
from C:/Ruby193/bin/guard:23:in `<main>'
我认为问题在于guard / phpunit是一个废弃的项目,并且尚未更新以支持最新的后卫。我认为这是因为当我删除所有与防护2.2.4相关的宝石文件并且仅留下与防护1.8.3防护相关的文件时将运行并观察文件并运行phpunit一次(失败它不应该)然后拒绝继续看着它不能完全发挥作用,但又向前迈进了一步。
我不是rubyist,但是guard / phpunit中的代码看起来很简单,我很想知道
答案 0 :(得分:1)
我认为问题在于guard / phpunit是一个废弃的项目,并且尚未更新以支持最新的后卫。
没有必要为最新的Guard版本升级Guard插件,因为这些更改是向后兼容的。
通常,您需要安装Bundler来管理您的宝石,并为应用程序设置加载路径以查找相关的宝石。所以如果你有例如您Gemfile
source 'https://rubygems.org'
ruby '2.0.0'
gem 'guard-phpunit'
然后你可以用
安装Guard和Guard :: PhpUnitbundle exec guard
另外,您是否看到guard-phpunit2
已发布为{{1}}?
答案 1 :(得分:0)
我遇到了这个问题,而且非常痛苦。目前我切换到linux,这就是为什么我无法测试解决方案。但它应该可以正常工作。
- 注意:
希望它有效。手指交叉。
答案 2 :(得分:0)
我有同样的问题。 我使用guard-phpunit2和这个Guardfile
guard 'phpunit2', :cli => '--colors', :tests_path => 'tests', :command => "./vendor/bin/phpunit" do
watch(%r{^.+Test\.php$})
end
现在工作正常