hawx / guard-sass

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

ERROR: Rails.root is nil! (RuntimeError) #30

Closed aaronchi closed 12 years ago

aaronchi commented 12 years ago

I'm getting this after upgrading to guard 1.1

ERROR: Rails.root is nil! (RuntimeError)
/Users/aaron/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/sass-3.1.19/lib/sass/util.rb:370:in `rails_root'
/Users/aaron/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/sass-3.1.19/lib/sass/plugin/rails.rb:11:in `default_options'
/Users/aaron/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/sass-3.1.19/lib/sass/plugin/configuration.rb:33:in `options'
/Users/aaron/.rbenv/versions/1.9.3-p194-perf/lib/ruby/gems/1.9.1/gems/sass-3.1.19/lib/sass/plugin/compiler.rb:38:in `initialize
hawx commented 12 years ago

Could you paste your Gemfile and Guardfile and describe what you did to get the error please.

aaronchi commented 12 years ago

All I do is add guard-sass to gemfile and if I start guard, it errors. Error is also reported here (https://github.com/chriseppstein/compass/issues/824) but this seems to be dependent on guard-sass being in the gemfile. Even when compass is not loaded, it still errors.

hawx commented 12 years ago

That issue is totally unrelated to guard-sass, if you are using compass then maybe you should be using guard-compass instead of guard-sass.

payneio commented 12 years ago

Actually, it seems like guard-sass is trying to use sass before Rails.root is available?

hawx commented 12 years ago

I’ve found a solution. guard-sass doesn’t need rails to work. So if you put it into a bundler group which isn’t loaded by Rails everything is ok. For example,

group :railsless do
  gem 'guard-sass'
end
pjg commented 12 years ago

I've also run into this issue and I've devised another workaround:

gem 'guard-sass', :require => false

Perhaps this problem is because of this commit bab96abd5da8eb?

straydogstudio commented 12 years ago

I've also run into this after a bundle update.

In lib/guard/sass.rb, if you reinstate the two autoload lines from 0.6.0, and comment out the requires at the bottom, things appear to work again. This suggests commit bab96ab is the source. But this is odd, considering the stack trace identifies the "require 'sass/plugin'" on line 1 as the source.

For extra measure, I tested each require statement separately. Either one causes the error.

For now, I'm running 0.6.0.

straydogstudio commented 12 years ago

Doh. Not really looking at my configuration. :require => false works fine.

chriscoyier commented 11 years ago

This was helpful to me too - :require => false worked.

nilsborg commented 11 years ago

dito! thx (also makes perfect sense)

mine looks like this now:

group :development do
  gem 'guard-livereload', require: false
  gem 'guard-sass'      , require: false
  gem 'rack-livereload'
  gem 'rb-fsevent',       require: false
end
ronniebermejo commented 11 years ago

Also check the gem using sass is required after sass