1

在我的 OSX 系统上,我正在尝试使用 Guard-Haml 将我的 HAML 自动编译为 HTML。但是,当守卫正在运行并尝试编译时,我得到了下面的错误,如图 1 所示。我已经安装了BunderGuard。由于NameError: uninitialized constant Guard::Haml::Bundler,我尝试安装了guard-bundler。但这并没有解决问题。关于这里需要做什么的任何见解?

谢谢蒂姆

...
14:33:05 - ERROR - Guard::Haml failed to achieve its <run_all>, exception was:
> [#0D0BB9E910E9] NameError: uninitialized constant Guard::Haml::Bundler
> [#0D0BB9E910E9] /Library/Ruby/Gems/1.8/gems/guard-haml-0.5/lib/guard/haml.rb:44:in `run_on_changes'
> [#0D0BB9E910E9] /Library/Ruby/Gems/1.8/gems/guard-haml-0.5/lib/guard/haml.rb:36:in `each'
> [#0D0BB9E910E9] /Library/Ruby/Gems/1.8/gems/guard-haml-0.5/lib/guard/haml.rb:36:in `run_on_changes'
> [#0D0BB9E910E9] /Library/Ruby/Gems/1.8/gems/guard-haml-0.5/lib/guard/haml.rb:32:in `run_all'
> [#0D0BB9E910E9] /Library/Ruby/Gems/1.8/gems/guard-1.8.0/lib/guard/runner.rb:99:in `send'
> [#0D0BB9E910E9] /Library/Ruby/Gems/1.8/gems/guard-1.8.0/lib/guard/runner.rb:99:in `run_supervised_task'
> [#0D0BB9E910E9] /Library/Ruby/Gems/1.8/gems/guard-1.8.0/lib/guard/runner.rb:97:in `catch'
> [#0D0BB9E910E9] /Library/Ruby/Gems/1.8/gems/guard-1.8.0/lib/guard/runner.rb:97:in `run_supervised_task'
> [#0D0BB9E910E9] /Library/Ruby/Gems/1.8/gems/guard-1.8.0/lib/guard/runner.rb:54:in `run'
> [#0D0BB9E910E9] /Library/Ruby/Gems/1.8/gems/guard-1.8.0/lib/guard/runner.rb:175:in `scoped_guards'
> [#0D0BB9E910E9] /Library/Ruby/Gems/1.8/gems/guard-1.8.0/lib/guard/runner.rb:173:in `each'
> [#0D0BB9E910E9] /Library/Ruby/Gems/1.8/gems/guard-1.8.0/lib/guard/runner.rb:173:in `scoped_guards'
> [#0D0BB9E910E9] /Library/Ruby/Gems/1.8/gems/guard-1.8.0/lib/guard/runner.rb:172:in `catch'
> [#0D0BB9E910E9] /Library/Ruby/Gems/1.8/gems/guard-1.8.0/lib/guard/runner.rb:172:in `scoped_guards'
> [#0D0BB9E910E9] /Library/Ruby/Gems/1.8/gems/guard-1.8.0/lib/guard/runner.rb:170:in `each'
> [#0D0BB9E910E9] /Library/Ruby/Gems/1.8/gems/guard-1.8.0/lib/guard/runner.rb:170:in `scoped_guards'
> [#0D0BB9E910E9] /Library/Ruby/Gems/1.8/gems/guard-1.8.0/lib/guard/runner.rb:53:in `run'
> [#0D0BB9E910E9] /Library/Ruby/Gems/1.8/gems/lumberjack-1.0.3/lib/lumberjack.rb:27:in `unit_of_work'
...

图1:错误输出

source 'https://rubygems.org'

group :development do
  gem 'execjs'
  gem 'therubyracer', :platforms => :ruby
  gem 'guard-bundler'
  gem 'guard'
  gem 'guard-haml'
  gem 'guard-livereload'
  gem 'libnotify'
  gem 'rb-inotify', :require => false
  gem 'rb-fsevent', :require => false
  gem 'rb-fchange', :require => false

  gem 'compass'
  gem 'ceaser-easing'
  gem 'html5-boilerplate'
end

图 2:Gemfile

4

1 回答 1

3

看起来guard-haml依赖于 Bundler,但仅将其添加为 development dependency

我对test.rb文件中的内容进行了快速测试

::Bundler.root.to_s

用 Ruby 运行它失败了

$ ruby test
test:1:in `<main>': uninitialized constant Bundler (NameError)

但是运行它可以bundle exec正常工作:

$ bundle exec test

所以要让guard-haml工作,你需要用Bundler运行它:

$ bundle exec guard
于 2013-04-28T13:14:19.120 回答