Compass / compass

Compass is no longer actively maintained. Compass is a Stylesheet Authoring Environment that makes your website design simpler to implement and easier to maintain.
http://compass-style.org
Other
6.72k stars 1.18k forks source link

Compilation error when using `compass watch` and `compass-import-once` #1868

Closed kmontag closed 1 year ago

kmontag commented 10 years ago

I'm getting a nil error in compass watch when making changes in a certain order if compass-import-once is activated. There seem to be a few things that can trigger it, but it's consistently reproducible using https://github.com/kmontag/compass-import-once-error by running compass watch, and then:

$ echo "\n" >> sass/_imported.sass && sleep 1 && echo "\n" >> sass/importer1.sass
$ # (sleep just needs to run long enough for the watcher to pick up the first change)

Here's the full error that pops up:

[Listen warning]: Change block raise an execption: undefined method `to_tree' for nil:NilClass
Backtrace:
    /home/vagrant/.rvm/gems/ruby-2.1.3/gems/sass-3.4.7/lib/sass/plugin/staleness_checker.rb:187:in `tree'
    /home/vagrant/.rvm/gems/ruby-2.1.3/gems/sass-3.4.7/lib/sass/plugin/staleness_checker.rb:174:in `compute_dependencies'
    /home/vagrant/.rvm/gems/ruby-2.1.3/gems/sass-3.4.7/lib/sass/plugin/staleness_checker.rb:149:in `dependencies'
    /home/vagrant/.rvm/gems/ruby-2.1.3/gems/sass-3.4.7/lib/sass/plugin/staleness_checker.rb:125:in `dependencies_stale?'
    /home/vagrant/.rvm/gems/ruby-2.1.3/gems/sass-3.4.7/lib/sass/plugin/staleness_checker.rb:166:in `block in dependency_updated?'
    /home/vagrant/.rvm/gems/ruby-2.1.3/gems/sass-3.4.7/lib/sass/plugin/staleness_checker.rb:125:in `each'
    /home/vagrant/.rvm/gems/ruby-2.1.3/gems/sass-3.4.7/lib/sass/plugin/staleness_checker.rb:125:in `any?'
    /home/vagrant/.rvm/gems/ruby-2.1.3/gems/sass-3.4.7/lib/sass/plugin/staleness_checker.rb:125:in `dependencies_stale?'
    /home/vagrant/.rvm/gems/ruby-2.1.3/gems/sass-3.4.7/lib/sass/plugin/staleness_checker.rb:166:in `block in dependency_updated?'
    /home/vagrant/.rvm/gems/ruby-2.1.3/gems/sass-3.4.7/lib/sass/plugin/staleness_checker.rb:81:in `call'
    /home/vagrant/.rvm/gems/ruby-2.1.3/gems/sass-3.4.7/lib/sass/plugin/staleness_checker.rb:81:in `stylesheet_modified_since?'
    /home/vagrant/.rvm/gems/ruby-2.1.3/gems/sass-3.4.7/lib/sass/plugin/staleness_checker.rb:69:in `stylesheet_needs_update?'
    /home/vagrant/.rvm/gems/ruby-2.1.3/gems/sass-3.4.7/lib/sass/plugin/compiler.rb:211:in `block in update_stylesheets'
    /home/vagrant/.rvm/gems/ruby-2.1.3/gems/sass-3.4.7/lib/sass/plugin/compiler.rb:209:in `each'
    /home/vagrant/.rvm/gems/ruby-2.1.3/gems/sass-3.4.7/lib/sass/plugin/compiler.rb:209:in `update_stylesheets'
    /home/vagrant/.rvm/gems/ruby-2.1.3/gems/sass-3.4.7/lib/sass/plugin/compiler.rb:469:in `on_file_changed'
    /home/vagrant/.rvm/gems/ruby-2.1.3/gems/sass-3.4.7/lib/sass/plugin/compiler.rb:328:in `block in watch'
    /home/vagrant/.rvm/gems/ruby-2.1.3/gems/sass-3.4.7/vendor/listen/lib/listen/listener.rb:252:in `call'
    /home/vagrant/.rvm/gems/ruby-2.1.3/gems/sass-3.4.7/vendor/listen/lib/listen/listener.rb:252:in `on_change'
    /home/vagrant/.rvm/gems/ruby-2.1.3/gems/sass-3.4.7/vendor/listen/lib/listen/listener.rb:290:in `block in initialize_adapter'
    /home/vagrant/.rvm/gems/ruby-2.1.3/gems/sass-3.4.7/vendor/listen/lib/listen/adapter.rb:254:in `call'
    /home/vagrant/.rvm/gems/ruby-2.1.3/gems/sass-3.4.7/vendor/listen/lib/listen/adapter.rb:254:in `report_changes'
    /home/vagrant/.rvm/gems/ruby-2.1.3/gems/sass-3.4.7/vendor/listen/lib/listen/adapter.rb:323:in `poll_changed_directories'
    /home/vagrant/.rvm/gems/ruby-2.1.3/gems/sass-3.4.7/vendor/listen/lib/listen/adapter.rb:299:in `block in start_poller'

No error if the same changes are made without compass-import-once being activated.

kmontag commented 10 years ago

Ah, looks like maybe the same as #1851

kmontag commented 9 years ago

For anyone else wanting a quick fix, this seems to do the trick, though I'm not totally sure whether it has unintended side effects (place above require 'compass/import-once/activate' in compass.rb):

require 'compass/import-once/importer'
module Compass::ImportOnce::Importer
  def find(uri, options, *args)
    uri, force_import = handle_force_import(uri.gsub(/^\(NOT IMPORTED\) /, ''))
    maybe_replace_with_dummy_engine(super(uri, options, *args), options, force_import)
  end
end
KoderES commented 8 years ago

Got this error on 22-oct-2016 after upgrading to Mac OS Sierra. I'm using compass.app https://github.com/KKBOX/compassapp/releases

Solution aported by @kmontag solved my problem

require 'compass/import-once/importer' module Compass::ImportOnce::Importer def find(uri, options, args) uri, force_import = handle_force_import(uri.gsub(/^(NOT IMPORTED) /, '')) maybe_replace_with_dummy_engine(super(uri, options, args), options, force_import) end end

Thank you very much.