为什么Guard Livereload没有启动服务器?

时间:2014-12-18 18:44:38

标签: ruby-on-rails guard livereload

我在我的新Rails项目上设置了Guard和Guar-Livereload,类似于我之前的一个:Gemfile:

group :development do
    gem 'spork-rails', '4.0.0'
    gem 'guard-spork', '1.5.0'
    gem 'childprocess'
    gem "rspec-rails"
    gem 'guard-livereload', require: false
    gem 'spring'
    gem "guard-rspec"
end

在我的Guardfile中:

guard 'livereload' do
  watch(%r{app/views/.+\.(erb|haml|slim)$})
  watch(%r{app/helpers/.+\.rb})
  watch(%r{app/assets/.+\.rb})
  watch(%r{app/assets/.+\.(css|js|scss|jpg|png)})
  watch(%r{public/.+\.(css|js|html)})
  watch(%r{config/locales/.+\.yml})
  # Rails Assets Pipeline
  watch(%r{(app|vendor)(/assets/\w+/(.+\.(css|js|html|png|jpg))).*}) { |m| "/assets/#{m[3]}" }
end

在发出命令guard init guard-livereload后创建的。当我发出guard时,我可以看到以下消息:

18:35:41 - INFO - Guard is using TerminalTitle to send notifications.
18:35:43 - INFO - Guard::RSpec is running
18:35:43 - INFO - LiveReload is waiting for a browser to connect.
18:35:43 - INFO - Guard is now watching at             '/Volumes/volume/Users/myuser/Documents/RubyApps/myapp'
[1] guard(main)>

但服务器无法启动,但是如果我rails s服务器将在前端启动并可见。这让我相信这个问题与Guard有关。有人能指出我正确的方向吗?

非常感谢

EDIT在运行guard -d后添加了控制台:

18:31:56 - DEBUG - Command execution: emacsclient --eval '1' 2> /dev/null || echo 'N/A'
18:31:56 - INFO - Guard is using TerminalTitle to send notifications.
18:31:57 - DEBUG - Command execution: hash stty
18:31:57 - DEBUG - Guard starts all plugins
18:31:57 - DEBUG - Hook :start_begin executed for Guard::RSpec
18:31:57 - INFO - Guard::RSpec is running
18:31:57 - DEBUG - Hook :start_end executed for Guard::RSpec
18:31:57 - DEBUG - Hook :start_begin executed for Guard::LiveReload
18:31:57 - DEBUG - Hook :start_end executed for Guard::LiveReload
18:31:57 - INFO - LiveReload is waiting for a browser to connect.
18:31:57 - INFO - Guard is now watching at    '/Volumes/fenix/Users/wagner/Documents/htdocs/RubyApps/turing'
18:31:57 - DEBUG - Start interactor
18:31:57 - DEBUG - Command execution: stty -g 2>/dev/null`

1 个答案:

答案 0 :(得分:0)

查看@ec2最近对此的评论:

  

对于livereload,使用' -d'守卫。选项(bundle exec guard -d)你应该看到为Guard :: LiveReload执行的Hook:run_on_modifications_begin。如果您收到该消息,请告诉我们(下一步取决于答案)。当然,确保在浏览器中实际启用livereload(我必须在每次启动项目时启用它) - 理想情况下,只需在浏览器中打开一个静态html文件,编辑该文件并检查 - 它应该可以正常工作。