metaskills / less-rails

:-1: :train: Less.js For Rails
http://github.com/metaskills/less-rails
MIT License
340 stars 133 forks source link

`register_preprocessor` error with sprockets 3 #111

Closed TALlama closed 8 years ago

TALlama commented 9 years ago

A new rails app with sprockets 3 and less-rails will fail to initialize:

[16:30][tal@ravenhurst:~/code]$ rails -v
Rails 4.2.4
[16:30][tal@ravenhurst:~/code]$ rails new sample
# snip: created files
Resolving dependencies....
Using rake 10.4.2
Using i18n 0.7.0
Using json 1.8.3
Using minitest 5.8.1
Using thread_safe 0.3.5
Using tzinfo 1.2.2
Using activesupport 4.2.4
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile 0.6.2
Using nokogiri 1.6.6.2
Using rails-deprecated_sanitizer 1.0.3
Using rails-dom-testing 1.0.7
Using loofah 2.0.3
Using rails-html-sanitizer 1.0.2
Using actionview 4.2.4
Using rack 1.6.4
Using rack-test 0.6.3
Using actionpack 4.2.4
Using globalid 0.3.6
Using activejob 4.2.4
Using mime-types 2.6.2
Using mail 2.6.3
Using actionmailer 4.2.4
Using activemodel 4.2.4
Using arel 6.0.3
Using activerecord 4.2.4
Using debug_inspector 0.0.2
Using binding_of_caller 0.7.2
Using bundler 1.10.6
Using byebug 6.0.2
Using coffee-script-source 1.9.1.1
Using execjs 2.6.0
Using coffee-script 2.4.1
Using thor 0.19.1
Using railties 4.2.4
Using coffee-rails 4.1.0
Using multi_json 1.11.2
Using jbuilder 2.3.2
Using jquery-rails 4.0.5
Using sprockets 3.4.0
Using sprockets-rails 2.3.3
Using rails 4.2.4
Using rdoc 4.2.0
Using sass 3.4.18
Using tilt 2.0.1
Using sass-rails 5.0.4
Using sdoc 0.4.1
Using spring 1.4.0
Using sqlite3 1.3.10
Using turbolinks 2.5.3
Using uglifier 2.7.2
Using web-console 2.2.1
Bundle complete! 12 Gemfile dependencies, 53 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
         run  bundle exec spring binstub --all
* bin/rake: spring inserted
* bin/rails: spring inserted
[16:30][tal@ravenhurst:~/code]$ cd sample/
[16:30][tal@ravenhurst:~/code/sample]$ cat >> Gemfile
gem 'less-rails'
gem 'sprockets-rails', github: 'rails/sprockets-rails', branch: 'master'
gem 'therubyracer'
[16:31][tal@ravenhurst:~/code/sample]$ bundle
Updating git://github.com/rails/sprockets-rails.git
Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies...
Using rake 10.4.2
Using i18n 0.7.0
Using json 1.8.3
Using minitest 5.8.1
Using thread_safe 0.3.5
Using tzinfo 1.2.2
Using activesupport 4.2.4
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile 0.6.2
Using nokogiri 1.6.6.2
Using rails-deprecated_sanitizer 1.0.3
Using rails-dom-testing 1.0.7
Using loofah 2.0.3
Using rails-html-sanitizer 1.0.2
Using actionview 4.2.4
Using rack 1.6.4
Using rack-test 0.6.3
Using actionpack 4.2.4
Using globalid 0.3.6
Using activejob 4.2.4
Using mime-types 2.6.2
Using mail 2.6.3
Using actionmailer 4.2.4
Using activemodel 4.2.4
Using arel 6.0.3
Using activerecord 4.2.4
Using debug_inspector 0.0.2
Using binding_of_caller 0.7.2
Using bundler 1.10.6
Using byebug 6.0.2
Using coffee-script-source 1.9.1.1
Using execjs 2.6.0
Using coffee-script 2.4.1
Using thor 0.19.1
Using railties 4.2.4
Using coffee-rails 4.1.0
Using commonjs 0.2.7
Using multi_json 1.11.2
Using jbuilder 2.3.2
Using jquery-rails 4.0.5
Using less 2.6.0
Using sprockets 3.4.0
Using tilt 2.0.1
Using less-rails 2.7.0
Using sprockets-rails 3.0.0.beta3 (was 2.3.3) from git://github.com/rails/sprockets-rails.git (at master)
Using rails 4.2.4
Using rdoc 4.2.0
Using sass 3.4.18
Using sass-rails 5.0.4
Using sdoc 0.4.1
Using spring 1.4.0
Using sqlite3 1.3.10
Using turbolinks 2.5.3
Using uglifier 2.7.2
Using web-console 2.2.1
Bundle complete! 14 Gemfile dependencies, 56 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
[16:31][tal@ravenhurst:~/code/sample]$ rails c
/Users/tal/.rvm/gems/ruby-2.1.6@recruit/gems/less-rails-2.7.0/lib/less/rails/railtie.rb:19:in `block in <class:Railtie>': undefined method `register_preprocessor' for nil:NilClass (NoMethodError)
    from /Users/tal/.rvm/gems/ruby-2.1.6@recruit/gems/railties-4.2.4/lib/rails/initializable.rb:30:in `instance_exec'
    from /Users/tal/.rvm/gems/ruby-2.1.6@recruit/gems/railties-4.2.4/lib/rails/initializable.rb:30:in `run'
    from /Users/tal/.rvm/gems/ruby-2.1.6@recruit/gems/railties-4.2.4/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /Users/tal/.rvm/rubies/ruby-2.1.6/lib/ruby/2.1.0/tsort.rb:226:in `block in tsort_each'
    from /Users/tal/.rvm/rubies/ruby-2.1.6/lib/ruby/2.1.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
    from /Users/tal/.rvm/rubies/ruby-2.1.6/lib/ruby/2.1.0/tsort.rb:427:in `each_strongly_connected_component_from'
    from /Users/tal/.rvm/rubies/ruby-2.1.6/lib/ruby/2.1.0/tsort.rb:347:in `block in each_strongly_connected_component'
    from /Users/tal/.rvm/rubies/ruby-2.1.6/lib/ruby/2.1.0/tsort.rb:345:in `each'
    from /Users/tal/.rvm/rubies/ruby-2.1.6/lib/ruby/2.1.0/tsort.rb:345:in `call'
    from /Users/tal/.rvm/rubies/ruby-2.1.6/lib/ruby/2.1.0/tsort.rb:345:in `each_strongly_connected_component'
    from /Users/tal/.rvm/rubies/ruby-2.1.6/lib/ruby/2.1.0/tsort.rb:224:in `tsort_each'
    from /Users/tal/.rvm/rubies/ruby-2.1.6/lib/ruby/2.1.0/tsort.rb:205:in `tsort_each'
    from /Users/tal/.rvm/gems/ruby-2.1.6@recruit/gems/railties-4.2.4/lib/rails/initializable.rb:54:in `run_initializers'
    from /Users/tal/.rvm/gems/ruby-2.1.6@recruit/gems/railties-4.2.4/lib/rails/application.rb:352:in `initialize!'
    from /Users/tal/code/sample/config/environment.rb:5:in `<top (required)>'
    from /Users/tal/.rvm/gems/ruby-2.1.6@recruit/gems/spring-1.4.0/lib/spring/application.rb:92:in `require'
    from /Users/tal/.rvm/gems/ruby-2.1.6@recruit/gems/spring-1.4.0/lib/spring/application.rb:92:in `preload'
    from /Users/tal/.rvm/gems/ruby-2.1.6@recruit/gems/spring-1.4.0/lib/spring/application.rb:143:in `serve'
    from /Users/tal/.rvm/gems/ruby-2.1.6@recruit/gems/spring-1.4.0/lib/spring/application.rb:131:in `block in run'
    from /Users/tal/.rvm/gems/ruby-2.1.6@recruit/gems/spring-1.4.0/lib/spring/application.rb:125:in `loop'
    from /Users/tal/.rvm/gems/ruby-2.1.6@recruit/gems/spring-1.4.0/lib/spring/application.rb:125:in `run'
    from /Users/tal/.rvm/gems/ruby-2.1.6@recruit/gems/spring-1.4.0/lib/spring/application/boot.rb:18:in `<top (required)>'
    from /Users/tal/.rvm/rubies/ruby-2.1.6/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /Users/tal/.rvm/rubies/ruby-2.1.6/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from -e:1:in `<main>'
TALlama commented 9 years ago

If it helps, it looks like sass-rails did the transition here.

betesh commented 8 years ago

Possible duplicate of PR #106?

imechemi commented 8 years ago

FYI, this happened to me when I quit terminal without shutting down the server and when I opened my terminal again and start my server, I saw this errors in stack trace. I used to kill the server process when I forget to quit the server, but now for this error I can't even find the process tied to the rails server.

xeron commented 8 years ago

I'm still getting this error, even with less-rails 2.7.0:

DEBUG [9c2d29b8]    rake aborted!
DEBUG [9c2d29b8]    NoMethodError: undefined method `register_preprocessor' for nil:NilClass
DEBUG [9c2d29b8]    /home/webmaster/www/gcal-sms/shared/bundle/ruby/2.1.0/gems/less-rails-2.7.0/lib/less/rails/railtie.rb:19:in `block in <class:Railtie>'
/home/webmaster/www/gcal-sms/shared/bundle/ruby/2.1.0/gems/railties-4.2.5/lib/rails/initializable.rb:30:in `instance_exec'
/home/webmaster/www/gcal-sms/shared/bundle/ruby/2.1.0/gems/railties-4.2.5/lib/rails/initializable.rb:30:in `run'
/home/webmaster/www/gcal-sms/shared/bundle/ruby/2.1.0/gems/railties-4.2.5/lib/rails/initializable.rb:55:in `block in run_initializers'
/home/webmaster/www/gcal-sms/shared/bundle/ruby/2.1.0/gems/railties-4.2.5/lib/rails/initializable.rb:54:in `run_initializers'
/home/webmaster/www/gcal-sms/shared/bundle/ruby/2.1.0/gems/railties-4.2.5/lib/rails/application.rb:352:in `initialize!'
/home/webmaster/www/gcal-sms/releases/20151230001814/config/environment.rb:5:in `<top (required)>'
/home/webmaster/www/gcal-sms/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:274:in `require'
/home/webmaster/www/gcal-sms/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:274:in `block in require'
/home/webmaster/www/gcal-sms/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:240:in `load_dependency'
/home/webmaster/www/gcal-sms/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:274:in `require'
/home/webmaster/www/gcal-sms/shared/bundle/ruby/2.1.0/gems/railties-4.2.5/lib/rails/application.rb:328:in `require_environment!'
/home/webmaster/www/gcal-sms/shared/bundle/ruby/2.1.0/gems/railties-4.2.5/lib/rails/application.rb:457:in `block in run_tasks_blocks'
/home/webmaster/www/gcal-sms/shared/bundle/ruby/2.1.0/gems/sprockets-rails-3.0.0/lib/sprockets/rails/task.rb:62:in `block (2 levels) in define'
DEBUG [9c2d29b8]    Tasks: TOP => environment
DEBUG [9c2d29b8]    (See full trace by running task with --trace)
jocubeit commented 8 years ago

@xeron me too. Rails 4.2.4, less-rails 2.7.0.

simi commented 8 years ago

update to 2.7.1

jocubeit commented 8 years ago

2.7.1 fixed the issue - thank you.