“NameError:未初始化的常量Guard :: Haml :: Bundler”

时间:2013-04-27 18:44:03

标签: ruby web-applications haml bundler guard

在我的OSX系统上,我正在尝试使用Guard-Haml将我的HAML自动编译为HTML。但是,当guard正在运行并尝试编译时,我得到下面的错误,如图1所示。我安装了BunderGuard。由于 NameError:未初始化的常量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

1 个答案:

答案 0 :(得分:3)

它看起来像guard-haml depends on Bundler,但只添加了it as 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