Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined method `clear' for nil:NilClass when attempting precompile #90

Open
tdwalton opened this issue Apr 2, 2014 · 1 comment
Open

Comments

@tdwalton
Copy link

tdwalton commented Apr 2, 2014

I get the following error output when attempting to precompile assets, in Rails 3.2.17.

myapp@beta-gateway1 ~/payment_segmentation $ RAILS_ENV=beta RAILS_GROUPS=assets bundle exec rake assets:precompile --trace
AssetSync: using /home/myapp/payment_segmentation/config/initializers/asset_sync.rb
** Invoke assets:precompile (first_time)
** Execute assets:precompile
** Invoke assets:precompile:all (first_time)
** Invoke assets:cache:clean (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Execute assets:cache:clean
rake aborted!
undefined method `clear' for nil:NilClass
/home/myapp/.rvm/gems/ruby-1.9.3-p484@myapp/gems/turbo-sprockets-rails3-0.3.11/lib/turbo-sprockets/tasks/assets.rake:184:in `block (3 levels) in <top (required)>'
/home/myapp/.rvm/gems/ruby-1.9.3-p484@myapp/gems/rake-10.0.3/lib/rake/task.rb:228:in `call'
/home/myapp/.rvm/gems/ruby-1.9.3-p484@myapp/gems/rake-10.0.3/lib/rake/task.rb:228:in `block in execute'
/home/myapp/.rvm/gems/ruby-1.9.3-p484@myapp/gems/rake-10.0.3/lib/rake/task.rb:223:in `each'
/home/myapp/.rvm/gems/ruby-1.9.3-p484@myapp/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute'
/home/myapp/.rvm/gems/ruby-1.9.3-p484@myapp/gems/rake-10.0.3/lib/rake/task.rb:166:in `block in invoke_with_call_chain'
/home/myapp/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/myapp/.rvm/gems/ruby-1.9.3-p484@myapp/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain'
/home/myapp/.rvm/gems/ruby-1.9.3-p484@myapp/gems/rake-10.0.3/lib/rake/task.rb:187:in `block in invoke_prerequisites'
/home/myapp/.rvm/gems/ruby-1.9.3-p484@myapp/gems/rake-10.0.3/lib/rake/task.rb:185:in `each'
/home/myapp/.rvm/gems/ruby-1.9.3-p484@myapp/gems/rake-10.0.3/lib/rake/task.rb:185:in `invoke_prerequisites'
/home/myapp/.rvm/gems/ruby-1.9.3-p484@myapp/gems/rake-10.0.3/lib/rake/task.rb:165:in `block in invoke_with_call_chain'
/home/myapp/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/myapp/.rvm/gems/ruby-1.9.3-p484@myapp/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain'
/home/myapp/.rvm/gems/ruby-1.9.3-p484@myapp/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke'
/home/myapp/.rvm/gems/ruby-1.9.3-p484@myapp/gems/turbo-sprockets-rails3-0.3.11/lib/turbo-sprockets/tasks/assets.rake:35:in `invoke_or_reboot_rake_task'
/home/myapp/.rvm/gems/ruby-1.9.3-p484@myapp/gems/turbo-sprockets-rails3-0.3.11/lib/turbo-sprockets/tasks/assets.rake:50:in `block (2 levels) in <top (required)>'
/home/myapp/.rvm/gems/ruby-1.9.3-p484@myapp/gems/rake-10.0.3/lib/rake/task.rb:228:in `call'
/home/myapp/.rvm/gems/ruby-1.9.3-p484@myapp/gems/rake-10.0.3/lib/rake/task.rb:228:in `block in execute'
/home/myapp/.rvm/gems/ruby-1.9.3-p484@myapp/gems/rake-10.0.3/lib/rake/task.rb:223:in `each'
/home/myapp/.rvm/gems/ruby-1.9.3-p484@myapp/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute'
/home/myapp/.rvm/gems/ruby-1.9.3-p484@myapp/gems/rake-10.0.3/lib/rake/task.rb:166:in `block in invoke_with_call_chain'
/home/myapp/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/myapp/.rvm/gems/ruby-1.9.3-p484@myapp/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain'
/home/myapp/.rvm/gems/ruby-1.9.3-p484@myapp/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke'
/home/myapp/.rvm/gems/ruby-1.9.3-p484@myapp/gems/rake-10.0.3/lib/rake/application.rb:143:in `invoke_task'
/home/myapp/.rvm/gems/ruby-1.9.3-p484@myapp/gems/rake-10.0.3/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/home/myapp/.rvm/gems/ruby-1.9.3-p484@myapp/gems/rake-10.0.3/lib/rake/application.rb:101:in `each'
/home/myapp/.rvm/gems/ruby-1.9.3-p484@myapp/gems/rake-10.0.3/lib/rake/application.rb:101:in `block in top_level'
/home/myapp/.rvm/gems/ruby-1.9.3-p484@myapp/gems/rake-10.0.3/lib/rake/application.rb:110:in `run_with_threads'
/home/myapp/.rvm/gems/ruby-1.9.3-p484@myapp/gems/rake-10.0.3/lib/rake/application.rb:95:in `top_level'
/home/myapp/.rvm/gems/ruby-1.9.3-p484@myapp/gems/rake-10.0.3/lib/rake/application.rb:73:in `block in run'
/home/myapp/.rvm/gems/ruby-1.9.3-p484@myapp/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/home/myapp/.rvm/gems/ruby-1.9.3-p484@myapp/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'
/home/myapp/.rvm/gems/ruby-1.9.3-p484@myapp/gems/rake-10.0.3/bin/rake:33:in `<top (required)>'
/home/myapp/.rvm/gems/ruby-1.9.3-p484@myapp/bin/rake:23:in `load'
/home/myapp/.rvm/gems/ruby-1.9.3-p484@myapp/bin/rake:23:in `<main>'
/home/myapp/.rvm/gems/ruby-1.9.3-p484@myapp/bin/ruby_executable_hooks:15:in `eval'
/home/myapp/.rvm/gems/ruby-1.9.3-p484@myapp/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => assets:precompile:all => assets:cache:clean

If I replace:

 namespace :cache do
    task :clean => ["assets:environment"] do
      FileUtils.mkdir_p(File.join(::Rails.root.to_s, *%w(tmp cache assets)))
        ::Rails.application.assets.cache.clear
    end
  end

with:

 namespace :cache do
    task :clean => ["assets:environment"] do
      FileUtils.mkdir_p(File.join(::Rails.root.to_s, *%w(tmp cache assets)))
      if ::Rails.application.assets.cache
          ::Rails.application.assets.cache.clear
      end
    end
  end

in /lib/turbo-sprockets/tasks/assets.rake, the error goes away, and asset compilation works.

I'd submit a pull request, but I'm not sure this is the correct fix, as it's not clear to me why ::Rails.application.assets.cache is nil.

Please advise.

austinrfnd added a commit to austinrfnd/turbo-sprockets-rails3 that referenced this issue Nov 15, 2014
@austinrfnd
Copy link

@ndbroadbent let me know if we have to modify the pull request in any way. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants