hawx / guard-sass

Guard::Sass automatically rebuilds sass files when modified (like sass --watch)
MIT License
88 stars 35 forks source link

Error on Ubuntu 13.04 #43

Closed tobinbradley closed 11 years ago

tobinbradley commented 11 years ago

I'm getting an error when guard starts on Ubuntu 13.04. Other than running guard I'm a total ruby noob and I have no idea what to do. I didn't get any error messages during installation of ruby or any of the gems, and ruby --version yields ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]. After the error message guard doesn't watch/update sass, but livereload and concat seem to be working fine. My only guards being loaded are guard-sass, guard-concat, and guard-livereload. It did work fine on 12.10, and I don't think any Ruby libraries changed versions (it was Ruby 1.9.3 on 12.10 as well).

Here's the guard error message. Any help would be greatly appreciated!

19:44:11 - INFO - Guard uses TerminalTitle to send notifications. 19:44:12 - INFO - Sass [0.50s] main.scss -> main.css

19:44:12 - ERROR - Guard::Sass failed to achieve its <start>, exception was:

[#2DD022E7B4D9] NoMethodError: undefined method reload_browser' for nil:NilClass [#2DD022E7B4D9] /var/lib/gems/1.9.1/gems/guard-livereload-1.4.0/lib/guard/livereload.rb:36:inrun_on_changes' [#2DD022E7B4D9] /var/lib/gems/1.9.1/gems/guard-sass-1.0.6/lib/guard/sass.rb:164:in block in notify' [#2DD022E7B4D9] /var/lib/gems/1.9.1/gems/guard-sass-1.0.6/lib/guard/sass.rb:162:ineach' [#2DD022E7B4D9] /var/lib/gems/1.9.1/gems/guard-sass-1.0.6/lib/guard/sass.rb:162:in notify' [#2DD022E7B4D9] /var/lib/gems/1.9.1/gems/guard-sass-1.0.6/lib/guard/sass.rb:146:inrun_on_changes' [#2DD022E7B4D9] /var/lib/gems/1.9.1/gems/guard-sass-1.0.6/lib/guard/sass.rb:97:in run_all' [#2DD022E7B4D9] /var/lib/gems/1.9.1/gems/guard-sass-1.0.6/lib/guard/sass.rb:90:instart' [#2DD022E7B4D9] /var/lib/gems/1.9.1/gems/guard-1.8.0/lib/guard/runner.rb:99:in block in run_supervised_task' [#2DD022E7B4D9] /var/lib/gems/1.9.1/gems/guard-1.8.0/lib/guard/runner.rb:97:incatch'
[#2DD022E7B4D9] /var/lib/gems/1.9.1/gems/guard-1.8.0/lib/guard/runner.rb:97:in run_supervised_task' [#2DD022E7B4D9] /var/lib/gems/1.9.1/gems/guard-1.8.0/lib/guard/runner.rb:54:inblock (2 levels) in run'
[#2DD022E7B4D9] /var/lib/gems/1.9.1/gems/guard-1.8.0/lib/guard/runner.rb:175:in block (3 levels) in scoped_guards' [#2DD022E7B4D9] /var/lib/gems/1.9.1/gems/guard-1.8.0/lib/guard/runner.rb:173:ineach'
[#2DD022E7B4D9] /var/lib/gems/1.9.1/gems/guard-1.8.0/lib/guard/runner.rb:173:in block (2 levels) in scoped_guards' [#2DD022E7B4D9] /var/lib/gems/1.9.1/gems/guard-1.8.0/lib/guard/runner.rb:172:incatch'
[#2DD022E7B4D9] /var/lib/gems/1.9.1/gems/guard-1.8.0/lib/guard/runner.rb:172:in block in scoped_guards' [#2DD022E7B4D9] /var/lib/gems/1.9.1/gems/guard-1.8.0/lib/guard/runner.rb:170:ineach'
[#2DD022E7B4D9] /var/lib/gems/1.9.1/gems/guard-1.8.0/lib/guard/runner.rb:170:in scoped_guards' [#2DD022E7B4D9] /var/lib/gems/1.9.1/gems/guard-1.8.0/lib/guard/runner.rb:53:inblock in run'
[#2DD022E7B4D9] /var/lib/gems/1.9.1/gems/lumberjack-1.0.3/lib/lumberjack.rb:27:in unit_of_work' [#2DD022E7B4D9] /var/lib/gems/1.9.1/gems/guard-1.8.0/lib/guard/runner.rb:52:inrun'
[#2DD022E7B4D9] /var/lib/gems/1.9.1/gems/guard-1.8.0/lib/guard.rb:192:in block in start' [#2DD022E7B4D9] /var/lib/gems/1.9.1/gems/guard-1.8.0/lib/guard.rb:368:inblock in within_preserved_state'
[#2DD022E7B4D9] internal:prelude:10:in synchronize' [#2DD022E7B4D9] /var/lib/gems/1.9.1/gems/guard-1.8.0/lib/guard.rb:365:inwithin_preserved_state'
[#2DD022E7B4D9] /var/lib/gems/1.9.1/gems/guard-1.8.0/lib/guard.rb:190:in start' [#2DD022E7B4D9] /var/lib/gems/1.9.1/gems/guard-1.8.0/lib/guard/cli.rb:110:instart' [#2DD022E7B4D9] /var/lib/gems/1.9.1/gems/thor-0.18.1/lib/thor/command.rb:27:in run' [#2DD022E7B4D9] /var/lib/gems/1.9.1/gems/thor-0.18.1/lib/thor/invocation.rb:120:ininvoke_command' [#2DD022E7B4D9] /var/lib/gems/1.9.1/gems/thor-0.18.1/lib/thor.rb:363:in dispatch' [#2DD022E7B4D9] /var/lib/gems/1.9.1/gems/thor-0.18.1/lib/thor/base.rb:439:instart' [#2DD022E7B4D9] /var/lib/gems/1.9.1/gems/guard-1.8.0/bin/guard:6:in <top (required)>' [#2DD022E7B4D9] /usr/local/bin/guard:23:inload' [#2DD022E7B4D9] /usr/local/bin/guard:23:in `

' 19:44:12 - INFO - Guard::Sass has just been fired 19:44:12 - INFO - Guard is now watching at '/home/tobin/Dropbox/code/web-template' 19:44:12 - INFO - LiveReload is waiting for a browser to connect.

tobinbradley commented 11 years ago

Did some more debugging (if you can call it that with my Ruby skills), and I have it fixed good enough for me. I'll leave it open here because it isn't quite working like it was in case anybody wants to dig into it more.

The :all_on_start option was causing the error. Here was the original line, which causes the error:

guard 'sass', :input => 'assets/sass', :output => 'public/css', :line_numbers => true, :all_on_start => true

And taking out :all_on_start => true made the error go away and everything seems to work again:

guard 'sass', :input => 'assets/sass', :output => 'public/css', :line_numbers => true

Here's the whole original Guardfile (with all_on_start still there):

# sass to css
guard 'sass', :input => 'assets/sass', :output => 'public/css', :line_numbers => true, :all_on_start => true

# This will concatenate the javascript files specified in :files to js/main.js
guard :concat, type: "js", files: %w(vendor/bootstrap/bootstrap-tooltip vendor/bootstrap/bootstrap-modal vendor/bootstrap/bootstrap-transition vendor/bootstrap/bootstrap-button vendor/bootstrap/bootstrap-popover vendor/bootstrap/bootstrap-alert vendor/jquery-ui-1.10.0.custom.min plugins map page), input_dir: "assets/scripts", output: "public/js/main"

# live reload
guard 'livereload' do
  watch(%r{public/js/.+\.(js)$})
  watch(%r{public/css/.+\.(css)})
  watch(%r{public/.+\.(html)$})
end

It doesn't preprocess SASS on start now of course, but I can live with that. It worked fine on 12.10, so there was probably a library change in 13.04 somewhere.

Thanks so much for guard-sass, it's awesome!

hawx commented 11 years ago

Great, I'm glad you've found a fix for it. I will look into the cause when I get time.

tobinbradley commented 11 years ago

Bit more for debugging purposes.

# sass to css
guard 'sass', :input => 'assets/sass', :output => 'public/css', :line_numbers => true, :all_on_start => true

# live reload
guard 'livereload' do
  watch(%r{public/js/.+\.(js)$})
  watch(%r{public/css/.+\.(css)})
  watch(%r{public/.+\.(html)$})
end

Kaboom.

# sass to css
guard 'sass', :input => 'assets/sass', :output => 'public/css', :line_numbers => true, :all_on_start => true

# live reload
guard 'livereload' do
  watch(%r{public/js/.+\.(js)$})
  #watch(%r{public/css/.+\.(css)})
  watch(%r{public/.+\.(html)$})
end

No errors (but Livereload isn't watching CSS).

# sass to css
guard 'sass', :input => 'assets/sass', :output => 'public/css', :line_numbers => true

# live reload
guard 'livereload' do
  watch(%r{public/js/.+\.(js)$})
  watch(%r{public/css/.+\.(css)})
  watch(%r{public/.+\.(html)$})
end

No errors, but doesn't preprocess SASS on start (I can live with that).

It looks like guard-livereload and guard-sass are head-butting there somehow. Beats me though - I haven't even done a Ruby hello world :).

hawx commented 11 years ago

Hi, I think I may have fixed the issue in the course of fixing #45. If you have time could you test out guard-sass version 1.1.0 (it's on rubygems) with :all_on_start => true and report back. Thanks.

tobinbradley commented 11 years ago

Fixed! Thanks for the help. Guard-sass is awesome!