alchaplinsky / polymer-rails

Polymer and web components for Ruby on Rails
MIT License
286 stars 80 forks source link

application isn't precompiled #57

Closed tddrmllr closed 9 years ago

tddrmllr commented 9 years ago

Getting the error below in production. How do I get rails to precompile that file?

ActionView::Template::Error (application isn't precompiled):
    7: <%= html_import_tag 'application' %>
  app/views/layouts/_backend_assets.html.erb:7:in `_app_views_layouts__backend_assets_html_erb___168557848280502284_98022700'
  app/views/layouts/backend.html.erb:8:in `_app_views_layouts_backend_html_erb__4017608478062651890_98532060' (pid:25890)
tddrmllr commented 9 years ago

I've tried adding application.html and components/* to the config.assets.precompile array, but no luck. Any guidance @alchapone?

rxever commented 9 years ago

In which file do you have application.html file? @tikitikifoofoo

alchaplinsky commented 9 years ago

Which version of rails/polymer-rails are you using?

tddrmllr commented 9 years ago

@alchapone I'm using 1.0.8 @rxever I just have this <%= html_import_tag 'application' %> in my application layout template.

tddrmllr commented 9 years ago

@alchapone using Rails 3.2.22 at the moment

lvillasica commented 9 years ago

@alchapone Having a problem precompiling my assets too.

rake aborted!
Sprockets::FileNotFound: couldn't find file '' with type 'text/html'
/Users/meisha/.rvm/gems/ruby-2.2.0@polymer-test/gems/sprockets-3.3.1/lib/sprockets/resolve.rb:64:in `resolve!'
/Users/meisha/.rvm/gems/ruby-2.2.0@polymer-test/gems/sprockets-3.3.1/lib/sprockets/context.rb:88:in `resolve'
/Users/meisha/.rvm/gems/ruby-2.2.0@polymer-test/gems/sprockets-3.3.1/lib/sprockets/legacy.rb:259:in `resolve_with_compat'
/Users/meisha/.rvm/gems/ruby-2.2.0@polymer-test/gems/sprockets-3.3.1/lib/sprockets/context.rb:142:in `require_asset'
/Users/meisha/.rvm/gems/ruby-2.2.0@polymer-test/gems/polymer-rails-1.1.0/lib/polymer-rails/processors/components_processor.rb:16:in `block in require_imports'
...

I believe this is related to <%= html_import_tag 'application' %>

slek120 commented 9 years ago

@lvillasica Same problem

Sprockets::FileNotFound: couldn't find file '' with type 'text/html'
/home/furima/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.3.3/lib/sprockets/resolve.rb:64:in `resolve!'
/home/furima/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.3.3/lib/sprockets/context.rb:88:in `resolve'
/home/furima/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.3.3/lib/sprockets/legacy.rb:259:in `resolve_with_compat'
/home/furima/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.3.3/lib/sprockets/context.rb:142:in `require_asset'
/home/furima/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/polymer-rails-1.1.0/lib/polymer-rails/processors/components_processor.rb:16:in `block in require_imports'
/home/furima/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/nokogiri-1.6.6.2/lib/nokogiri/xml/node_set.rb:187:in `block in each'
/home/furima/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/nokogiri-1.6.6.2/lib/nokogiri/xml/node_set.rb:186:in `upto'
/home/furima/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/nokogiri-1.6.6.2/lib/nokogiri/xml/node_set.rb:186:in `each'
/home/furima/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/polymer-rails-1.1.0/lib/polymer-rails/processors/components_processor.rb:15:in `require_imports'
/home/furima/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/polymer-rails-1.1.0/lib/polymer-rails/processors/components_processor.rb:8:in `process'
/home/furima/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/polymer-rails-1.1.0/lib/polymer-rails/processors/components_processor_v3.rb:19:in `call'
/home/furima/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/polymer-rails-1.1.0/lib/polymer-rails/processors/components_processor_v3.rb:14:in `call'

It's weird, precompile works on my mac but not on my ubuntu server. I tried removing some require lines and it works. It's hard to figure out which dependency is causing the problem.

slek120 commented 9 years ago

@lvillasica I was able to find out which component was causing the problem.

Use my fork to find out which file causes the error

gem 'polymer-rails', github: 'slek120/polymer-rails'

All I changed was

return components.blank? ? nil : components.first

to

return components.first unless components.blank?
raise StandardError, "Couldn't find file '#{file}' in '#{@context.pathname}'"
alchaplinsky commented 9 years ago

Could not reproduce this issue on my side. But if you guys can confirm that @slek120's fix solves the issue, I'd be glad to merge a PR.

slek120 commented 9 years ago

@alchapone it doesn't fix the issue. it just reports which component is causing the error for precompile.

I found that some components have tests which have dependencies not included in the component's dependencies (eg iron-ajax has tests that require web-component-tester and test-fixture). I don't know why it was trying to compile the test though.

I fixed it by changing

Rails.application.config.assets.paths << Rails.root.join('vendor', 'assets', 'components', '**')

to

Rails.application.config.assets.paths << Rails.root.join('vendor', 'assets', 'components', '*')
alchaplinsky commented 9 years ago

So this error is from polymer-elements-rails gem. I've already added test files to gitignore there, see v1.0.1