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

Fail to run rails app 4.2.5 with sprockets-rails 3.0.0 #291

Closed
Sega100500 opened this issue Dec 18, 2015 · 52 comments
Closed

Fail to run rails app 4.2.5 with sprockets-rails 3.0.0 #291

Sega100500 opened this issue Dec 18, 2015 · 52 comments

Comments

@Sega100500
Copy link

rails/rails#22661

Ruby 2.2.4
Rails 4.2.5

with sprockets-rails 3.0.0 rails application fail to run

I add in Gemfile:

gem 'sprockets-rails', '< 3.0.0'

then ALL WORK!

@rafaelfranca
Copy link
Member

Thank you for the issue. The reason that you application is not working may be because it is not ready to sprockets 3 yet, but to be able to help you we need a way to replicate the issue. Could you create a sample application reproducing this error?

@Sega100500
Copy link
Author

@rafaelfranca
"because it is not ready to sprockets 3 yet"

What features and requirements must be met?

@rafaelfranca
Copy link
Member

@Sega100500
Copy link
Author

@rafaelfranca
Pure Rails app 4.2.5 in production mode:

  1. No log reported
  2. Output:
Incomplete response received from application
``

@rafaelfranca
Copy link
Member

How can I reproduce it?

@Sega100500
Copy link
Author

@rafaelfranca
Just rails new test_app

In development mode all works, in production - Incomplete response received from application

layouts/application.rb

<!DOCTYPE html>
<html>
<head>
  <title>TestApp</title>
  <%# stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>
  <%# javascript_include_tag 'application', 'data-turbolinks-track' => true %>
  <%= csrf_meta_tags %>
</head>
<body>

<%= yield %>

</body>
</html>
class ApplicationController < ActionController::Base
  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  protect_from_forgery with: :exception

  def index

  end

end

index.html.erb:

TEXT

@Sega100500
Copy link
Author

@rafaelfranca
And...
I NOT use turbolinks and spring - turn off in Gemfile

@Sega100500
Copy link
Author

@rafaelfranca
application.js

//= require jquery2
//= require jquery_ujs
//##=## require turbolinks
//##=## require_tree .

application.css

 *##=## require_tree .
 *= require_self

@Sega100500
Copy link
Author

@rafaelfranca
I use Phusion Passenger for production

@rafaelfranca
Copy link
Member

I tried to reproduce it and could not. Could you try to change this application to reproduce it https://github.com/rafaelfranca/test_app?

@Sega100500
Copy link
Author

@rafaelfranca
Gemfile

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
## gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

# Use ActiveModel has_secure_password
gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'

  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  ## gem 'spring'
end
gem 'bcrypt', '~> 3.1.7'
gem 'therubyracer', platforms: :ruby

@rafaelfranca
Copy link
Member

Could you please fork my application, change it and commit the changes necessary to reproduce the problem?

@Sega100500
Copy link
Author

@rafaelfranca
Without

gem 'therubyracer', platforms: :ruby

rails s

/home/ruby/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:80:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'uglifier'. (Bundler::GemRequireError)
        from /home/ruby/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
        from /home/ruby/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `each'
        from /home/ruby/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `block in require'
        from /home/ruby/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `each'
        from /home/ruby/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `require'
        from /home/ruby/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler.rb:99:in `require'
        from /home/ruby/projects/test_app/config/application.rb:7:in `<top (required)>'
        from /home/ruby/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:78:in `require'
        from /home/ruby/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:78:in `block in server'
        from /home/ruby/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in `tap'
        from /home/ruby/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in `server'
        from /home/ruby/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
        from /home/ruby/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/commands.rb:17:in `<top (required)>'
        from bin/rails:9:in `require'
        from bin/rails:9:in `<main>'

@Sega100500
Copy link
Author

@rafaelfranca
Uncomment in your Gemfile gem 'therubyracer', platforms: :ruby and try again

@Sega100500
Copy link
Author

@rafaelfranca
In FULL application is IMPORTANT in production.log error:

Error
    at new JS_Parse_Error (<eval>:2659:11936)
    at js_error (<eval>:2659:12155)
    at croak (<eval>:2659:20622)
    at token_error (<eval>:2659:20759)
    at unexpected (<eval>:2659:20847)
    at block_ (<eval>:2659:26178)
    at ctor.body (<eval>:2659:25832)
    at function_ (<eval>:2659:25897)
    at expr_atom (<eval>:2659:28965)
    at maybe_unary (<eval>:2659:31652)):

I think it just is interconnected

@rafaelfranca
Copy link
Member

Tried everything you said as you can see here rafaelfranca/test_app@e276680 but still didn't reproduced.

It is something in your application or some dependency that you use. I can only help if I can reproduce it.

I'm closing this issue since I can't reproduce but fell free to comment here with a way to reproduce that I'll reopen

@Sega100500
Copy link
Author

@rafaelfranca
You use Ruby 2.2.4 ?

@rafaelfranca
Copy link
Member

Yes.

@Sega100500
Copy link
Author

Strange!
I download your app - it work
Now I find differences

@Sega100500
Copy link
Author

@rafaelfranca
In Engine
config/initializers/assets.rb

Rails.application.config.assets.precompile += ['admin/*.js', 'admin/*.css', 'admin/**/*.js', 'admin/**/*.css']
Rails.application.config.assets.precompile += ['admin/*.png', 'admin/**/*.png', 'admin/*.gif', 'admin/**/*.gif']
Rails.application.config.assets.precompile += ['admin/*.jpg', 'admin/**/*.jpg', 'admin/*.jpeg', 'admin/**/*.jpeg']

Rails.application.config.assets.precompile += ['ckeditor/*.js', 'ckeditor/*.css', 'ckeditor/**/*.js', 'ckeditor/**/*.css', 'ckeditor/*.md',

Rails.application.config.assets.paths << Admin::Engine.root.join('app','assets','images')
Rails.application.config.assets.paths << Admin::Engine.root.join('app','assets','images','admin')

It is valid for sprockets-rails 3.0.0 ?

@Sega100500
Copy link
Author

@rafaelfranca
Error occure when I attach my own Engine 'Admin'
But error occure in main application

@Sega100500
Copy link
Author

@rafaelfranca

Please help! Whats may be wrong?

@Sega100500
Copy link
Author

@rafaelfranca
without

Rails.application.config.assets.precompile += ['admin/*.png', 'admin/**/*.png', 'admin/*.gif', 'admin/**/*.gif']
Rails.application.config.assets.precompile += ['admin/*.jpg', 'admin/**/*.jpg', 'admin/*.jpeg', 'admin/**/*.jpeg']

when running Engine
Showing error:

Asset was not declared to be precompiled in production.
Add `Rails.application.config.assets.precompile += %w( admin/admin.png )` to `config/initializers/assets.rb` and restart your server

In development

@Sega100500
Copy link
Author

In environments/production:

config.assets.compile = true

@Sega100500
Copy link
Author

@rafaelfranca
In Engine and main_app used stylesheets and scripts with same names. Possible they conflict?

@Sega100500
Copy link
Author

@rafaelfranca
with

config.assets.compile = false

and

rake assets:precompile

Application RUN!
But... many images not displayed

@Sega100500
Copy link
Author

@rafaelfranca
For me using config.assets.compile = true is much more convenient than rake assets:precompile
But in sprockets-rails 3.0.0 it not work as It expected, as It early.

Engine 'Admin' I wrote itself, and I use It as local gem.

@rafaelfranca
Copy link
Member

All that is fine with sprockets-rails 3, but I guess you engine has something that has invalid JavaScript. I suggest to you to try to checks all your files in the engine.

@Sega100500
Copy link
Author

@rafaelfranca
All JavaScripts in Engine are valid and work - this Engine worked since 2012 without any problems. All script valid and checked by Time.
Only with sprockets-rails 3 this occure.
So may still not in this case?
Moreover, in development mode all works! Some problems with config.assets.compile = true in sprockets-rails 3 I think

@Sega100500
Copy link
Author

@rafaelfranca
I just experiment now. Wait

@rafaelfranca
Copy link
Member

sprockets-rails should not cause any JavaScript error because it doesn't handle any JavaScript. Before upgrading to sprockets-rails 3 are you using sprockets 2 or sprockets 3?

As it only happen when config.assets.compile is true it is not related with sprockets-rails since when that option is true you are compiling in production and that is job for sprockets, so it is more likely that your project was using sprockets 2 and now it is using sprockets 3.

@Sega100500
Copy link
Author

@rafaelfranca

  1. In main app config/initializers/assets.rb:
# Be sure to restart your server when you modify this file.

# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'

# Add additional assets to the asset load path
# Rails.application.config.assets.paths << Emoji.images_path

# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# Rails.application.config.assets.precompile += %w( search.js )
Rails.application.config.assets.precompile += ['*.js', '*.css', '**/*.js', '**/*.css']
Rails.application.config.assets.precompile += ['ckeditor/*.js', 'ckeditor/*.css', 'ckeditor/**/*.js', 'ckeditor/**/*.css', 'ckeditor/*.md',
  1. In Engine config\initializers\assets.rb:
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'

# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# Rails.application.config.assets.precompile += %w( search.js )
Rails.application.config.assets.precompile += ['admin/*.js', 'admin/*.css', 'admin/**/*.js', 'admin/**/*.css']
Rails.application.config.assets.precompile += ['admin/*.png', 'admin/**/*.png', 'admin/*.gif', 'admin/**/*.gif']
Rails.application.config.assets.precompile += ['admin/*.jpg', 'admin/**/*.jpg', 'admin/*.jpeg', 'admin/**/*.jpeg']

Rails.application.config.assets.precompile += ['ckeditor/*.js', 'ckeditor/*.css', 'ckeditor/**/*.js', 'ckeditor/**/*.css', 'ckeditor/*.md', 'ckeditor/*.txt', 'ckeditor/*.html' ]

Rails.application.config.assets.paths << Admin::Engine.root.join('app','assets','images')
Rails.application.config.assets.paths << Admin::Engine.root.join('app','assets','images','admin')

Even if I delete In Engine config\initializers\assets.rb then error occure.

@rafaelfranca
Copy link
Member

Try to remove ckeditor to see if the error still happen.

@Sega100500
Copy link
Author

@rafaelfranca
"Before upgrading to sprockets-rails 3 are you using sprockets 2 or sprockets 3"

I just run 'gem upgrade' and all application was crashed after sprockets-rails 3`` is upgraded from 2 to 3. In rails-generated Gemfile nogem sprockets-rails```. It upgraded automatically.

@rafaelfranca
Copy link
Member

can you check if you application was using sprockets 2 or sprockets 3 before the gem upgrade? Pay attention that I'm asking about sprockets not sprockets-rails.

@Sega100500
Copy link
Author

@rafaelfranca
I commented in main app:

# Rails.application.config.assets.precompile += ['ckeditor/*.js', 'ckeditor/*.css', 'ckeditor/**/*.js', 'ckeditor/**/*.css', 'ckeditor/*.md', 'ckeditor/*.txt', 'ckeditor/*.html' ]

Errror still present.
Wait. I try to turn off gem ckeditor.

@Sega100500
Copy link
Author

@rafaelfranca
Without ckeditor not working my 'Admin' - without 'Admin' not working all applicatioin.
May You add to your test_app gem ckeditor and verify?
I try do it with own pure application rails 4.2.5

@Sega100500
Copy link
Author

@rafaelfranca
Just add In Gemfile:

gem 'ckeditor'
gem 'paperclip'

and in main app config/initializers/assets.rb:

Rails.application.config.assets.precompile += ['*.js', '*.css', '**/*.js', '**/*.css']
Rails.application.config.assets.precompile += ['ckeditor/*.js', 'ckeditor/*.css', 'ckeditor/**/*.js', 'ckeditor/**/*.css', 'ckeditor/*.md', 'ckeditor/*.txt', 'ckeditor/*.html' ]

with config.assets.compile = true

@rafaelfranca
Copy link
Member

@Sega100500 have you verified that it breaks my application? I'm sorry but I can't do it right now, so it would be awesome if you fork my application do the changes yourself, see if it fails and open a PR to my application.

@Sega100500
Copy link
Author

@rafaelfranca
I now download YOUR application https://github.com/rafaelfranca/test_app

  1. Set config.assets.compile = true
  2. Add to Gemfile:
gem 'ckeditor'
gem 'paperclip'
  1. Add to config/initializers/assets.rb:
Rails.application.config.assets.precompile += ['*.js', '*.css', '**/*.js', '**/*.css']
Rails.application.config.assets.precompile += ['ckeditor/*.js', 'ckeditor/*.css', 'ckeditor/**/*.js', 'ckeditor/**/*.css', 'ckeditor/*.md', 'ckeditor/*.txt', 'ckeditor/*.html' ]

In development mode it work.
Run in production work too.

I try to create test Engine.

@Sega100500
Copy link
Author

@rafaelfranca

When I try to login to the 'Admin' the error log different:

I, [2015-12-19T00:33:45.455270 #8876]  INFO -- :   Rendered admin/app/views/admin/application/loginpage.html.erb (179.2ms)
I, [2015-12-19T00:33:45.455469 #8876]  INFO -- : Completed 500 Internal Server Error in 599ms (ActiveRecord: 112.0ms)
F, [2015-12-19T00:33:45.457927 #8876] FATAL -- : 
ActionView::Template::Error (Unexpected token: eof (undefined) (line: 16, col: 0, pos: 391)

Error
    at new JS_Parse_Error (<eval>:2659:11936)
    at js_error (<eval>:2659:12155)
    at croak (<eval>:2659:20622)
    at token_error (<eval>:2659:20759)
    at unexpected (<eval>:2659:20847)
    at block_ (<eval>:2659:26178)
    at ctor.body (<eval>:2659:25832)
    at function_ (<eval>:2659:25897)
    at expr_atom (<eval>:2659:28965)
    at maybe_unary (<eval>:2659:31652)):
    12: 
    13:     <meta charset="utf-8">
    14: 
    15:     <%= stylesheet_link_tag 'admin/reset-html5', :media => "all" %>
    16:     <%= stylesheet_link_tag  'admin/login', :media => "all" %>
    17: 
    18:     <%= csrf_meta_tags %>
  new JS_Parse_Error ((execjs):2659:11936)
  js_error ((execjs):2659:12155)
  croak ((execjs):2659:20622)
  token_error ((execjs):2659:20759)
  unexpected ((execjs):2659:20847)
  block_ ((execjs):2659:26178)
  ctor.body ((execjs):2659:25832)
  function_ ((execjs):2659:25897)
  expr_atom ((execjs):2659:28965)
  maybe_unary ((execjs):2659:31652)
  execjs (2.6.0) lib/execjs/ruby_racer_runtime.rb:47:in `rescue in block in call'
  execjs (2.6.0) lib/execjs/ruby_racer_runtime.rb:44:in `block in call'
  execjs (2.6.0) lib/execjs/ruby_racer_runtime.rb:75:in `block in lock'
  execjs (2.6.0) lib/execjs/ruby_racer_runtime.rb:73:in `call'
  execjs (2.6.0) lib/execjs/ruby_racer_runtime.rb:73:in `Locker'
  execjs (2.6.0) lib/execjs/ruby_racer_runtime.rb:73:in `lock'
  execjs (2.6.0) lib/execjs/ruby_racer_runtime.rb:43:in `call'
  uglifier (2.7.2) lib/uglifier.rb:212:in `run_uglifyjs'
  uglifier (2.7.2) lib/uglifier.rb:179:in `compile'
  sprockets (3.5.2) lib/sprockets/uglifier_compressor.rb:52:in `call'
  sprockets (3.5.2) lib/sprockets/uglifier_compressor.rb:28:in `call'
  sprockets (3.5.2) lib/sprockets/processor_utils.rb:75:in `call_processor'
  sprockets (3.5.2) lib/sprockets/processor_utils.rb:57:in `block in call_processors'
  sprockets (3.5.2) lib/sprockets/processor_utils.rb:56:in `reverse_each'
  sprockets (3.5.2) lib/sprockets/processor_utils.rb:56:in `call_processors'
  sprockets (3.5.2) lib/sprockets/loader.rb:134:in `load_from_unloaded'
  sprockets (3.5.2) lib/sprockets/loader.rb:60:in `block in load'
  sprockets (3.5.2) lib/sprockets/loader.rb:318:in `fetch_asset_from_dependency_cache'
  sprockets (3.5.2) lib/sprockets/loader.rb:44:in `load'
  sprockets (3.5.2) lib/sprockets/cached_environment.rb:20:in `block in initialize'
  sprockets (3.5.2) lib/sprockets/cached_environment.rb:47:in `yield'
  sprockets (3.5.2) lib/sprockets/cached_environment.rb:47:in `load'
  sprockets (3.5.2) lib/sprockets/base.rb:66:in `find_asset'
  sprockets (3.5.2) lib/sprockets/base.rb:73:in `find_all_linked_assets'
  sprockets (3.5.2) lib/sprockets/manifest.rb:142:in `block in find'
  sprockets (3.5.2) lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths'
  sprockets (3.5.2) lib/sprockets/path_utils.rb:225:in `block in stat_tree'
  sprockets (3.5.2) lib/sprockets/path_utils.rb:209:in `block in stat_directory'
  sprockets (3.5.2) lib/sprockets/path_utils.rb:206:in `each'
  sprockets (3.5.2) lib/sprockets/path_utils.rb:206:in `stat_directory'
  sprockets (3.5.2) lib/sprockets/path_utils.rb:224:in `stat_tree'
  sprockets (3.5.2) lib/sprockets/path_utils.rb:228:in `block in stat_tree'
  sprockets (3.5.2) lib/sprockets/path_utils.rb:209:in `block in stat_directory'
  sprockets (3.5.2) lib/sprockets/path_utils.rb:206:in `each'
  sprockets (3.5.2) lib/sprockets/path_utils.rb:206:in `stat_directory'
  sprockets (3.5.2) lib/sprockets/path_utils.rb:224:in `stat_tree'
  sprockets (3.5.2) lib/sprockets/path_utils.rb:228:in `block in stat_tree'
  sprockets (3.5.2) lib/sprockets/path_utils.rb:209:in `block in stat_directory'
  sprockets (3.5.2) lib/sprockets/path_utils.rb:206:in `each'
  sprockets (3.5.2) lib/sprockets/path_utils.rb:206:in `stat_directory'
  sprockets (3.5.2) lib/sprockets/path_utils.rb:224:in `stat_tree'
  sprockets (3.5.2) lib/sprockets/path_utils.rb:228:in `block in stat_tree'
  sprockets (3.5.2) lib/sprockets/path_utils.rb:209:in `block in stat_directory'
  sprockets (3.5.2) lib/sprockets/path_utils.rb:206:in `each'
  sprockets (3.5.2) lib/sprockets/path_utils.rb:206:in `stat_directory'
  sprockets (3.5.2) lib/sprockets/path_utils.rb:224:in `stat_tree'
  sprockets (3.5.2) lib/sprockets/path_utils.rb:228:in `block in stat_tree'
  sprockets (3.5.2) lib/sprockets/path_utils.rb:209:in `block in stat_directory'
  sprockets (3.5.2) lib/sprockets/path_utils.rb:206:in `each'
  sprockets (3.5.2) lib/sprockets/path_utils.rb:206:in `stat_directory'
  sprockets (3.5.2) lib/sprockets/path_utils.rb:224:in `stat_tree'
  sprockets (3.5.2) lib/sprockets/path_utils.rb:228:in `block in stat_tree'
  sprockets (3.5.2) lib/sprockets/path_utils.rb:209:in `block in stat_directory'
  sprockets (3.5.2) lib/sprockets/path_utils.rb:206:in `each'
  sprockets (3.5.2) lib/sprockets/path_utils.rb:206:in `stat_directory'
  sprockets (3.5.2) lib/sprockets/path_utils.rb:224:in `stat_tree'
  sprockets (3.5.2) lib/sprockets/path_utils.rb:228:in `block in stat_tree'
  sprockets (3.5.2) lib/sprockets/path_utils.rb:209:in `block in stat_directory'
  sprockets (3.5.2) lib/sprockets/path_utils.rb:206:in `each'
  sprockets (3.5.2) lib/sprockets/path_utils.rb:206:in `stat_directory'
  sprockets (3.5.2) lib/sprockets/path_utils.rb:224:in `stat_tree'
  sprockets (3.5.2) lib/sprockets/legacy.rb:105:in `each'
  sprockets (3.5.2) lib/sprockets/legacy.rb:105:in `block in logical_paths'
  sprockets (3.5.2) lib/sprockets/legacy.rb:104:in `each'
  sprockets (3.5.2) lib/sprockets/legacy.rb:104:in `logical_paths'
  sprockets (3.5.2) lib/sprockets/manifest.rb:140:in `find'
  sprockets-rails (3.0.0) lib/sprockets/railtie.rb:41:in `each'
  sprockets-rails (3.0.0) lib/sprockets/railtie.rb:41:in `map'
  sprockets-rails (3.0.0) lib/sprockets/railtie.rb:41:in `precompiled_assets'
  sprockets-rails (3.0.0) lib/sprockets/railtie.rb:34:in `asset_precompiled?'
  sprockets-rails (3.0.0) lib/sprockets/railtie.rb:205:in `block (3 levels) in <class:Railtie>'
  sprockets-rails (3.0.0) lib/sprockets/rails/helper.rb:346:in `call'
  sprockets-rails (3.0.0) lib/sprockets/rails/helper.rb:346:in `precompiled?'
  sprockets-rails (3.0.0) lib/sprockets/rails/helper.rb:350:in `raise_unless_precompiled_asset'
  sprockets-rails (3.0.0) lib/sprockets/rails/helper.rb:324:in `digest_path'
  sprockets-rails (3.0.0) lib/sprockets/rails/helper.rb:312:in `asset_path'
  sprockets-rails (3.0.0) lib/sprockets/rails/helper.rb:90:in `block in resolve_asset_path'
  sprockets-rails (3.0.0) lib/sprockets/rails/helper.rb:230:in `block in resolve_asset'
  sprockets-rails (3.0.0) lib/sprockets/rails/helper.rb:229:in `each'
  sprockets-rails (3.0.0) lib/sprockets/rails/helper.rb:229:in `detect'
  sprockets-rails (3.0.0) lib/sprockets/rails/helper.rb:229:in `resolve_asset'
  sprockets-rails (3.0.0) lib/sprockets/rails/helper.rb:89:in `resolve_asset_path'
  sprockets-rails (3.0.0) lib/sprockets/rails/helper.rb:79:in `compute_asset_path'
  actionview (4.2.5) lib/action_view/helpers/asset_url_helper.rb:135:in `asset_path'
  actionview (4.2.5) lib/action_view/helpers/asset_url_helper.rb:267:in `stylesheet_path'
  actionview (4.2.5) lib/action_view/helpers/asset_tag_helper.rb:100:in `block in stylesheet_link_tag'
  actionview (4.2.5) lib/action_view/helpers/asset_tag_helper.rb:96:in `map'
  actionview (4.2.5) lib/action_view/helpers/asset_tag_helper.rb:96:in `stylesheet_link_tag'
  sprockets-rails (3.0.0) lib/sprockets/rails/helper.rb:173:in `block in stylesheet_link_tag'
  sprockets-rails (3.0.0) lib/sprockets/rails/helper.rb:171:in `map'
  sprockets-rails (3.0.0) lib/sprockets/rails/helper.rb:171:in `stylesheet_link_tag'
  admin/app/views/admin/application/loginpage.html.erb:15:in `_admin_app_views_admin_application_loginpage_html_erb___3498399414066784484_69859847003860'
  actionview (4.2.5) lib/action_view/template.rb:145:in `block in render'
  activesupport (4.2.5) lib/active_support/notifications.rb:166:in `instrument'
  actionview (4.2.5) lib/action_view/template.rb:333:in `instrument'
  actionview (4.2.5) lib/action_view/template.rb:143:in `render'
  actionview (4.2.5) lib/action_view/renderer/template_renderer.rb:54:in `block (2 levels) in render_template'
  actionview (4.2.5) lib/action_view/renderer/abstract_renderer.rb:39:in `block in instrument'
  activesupport (4.2.5) lib/active_support/notifications.rb:164:in `block in instrument'
  activesupport (4.2.5) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (4.2.5) lib/active_support/notifications.rb:164:in `instrument'
  actionview (4.2.5) lib/action_view/renderer/abstract_renderer.rb:39:in `instrument'
  actionview (4.2.5) lib/action_view/renderer/template_renderer.rb:53:in `block in render_template'
  actionview (4.2.5) lib/action_view/renderer/template_renderer.rb:61:in `render_with_layout'
  actionview (4.2.5) lib/action_view/renderer/template_renderer.rb:52:in `render_template'
  actionview (4.2.5) lib/action_view/renderer/template_renderer.rb:14:in `render'
  actionview (4.2.5) lib/action_view/renderer/renderer.rb:42:in `render_template'
  actionview (4.2.5) lib/action_view/renderer/renderer.rb:23:in `render'
  actionview (4.2.5) lib/action_view/rendering.rb:100:in `_render_template'
  actionpack (4.2.5) lib/action_controller/metal/streaming.rb:217:in `_render_template'
  actionview (4.2.5) lib/action_view/rendering.rb:83:in `render_to_body'
  actionpack (4.2.5) lib/action_controller/metal/rendering.rb:32:in `render_to_body'
  actionpack (4.2.5) lib/action_controller/metal/renderers.rb:37:in `render_to_body'
  actionpack (4.2.5) lib/abstract_controller/rendering.rb:25:in `render'
  actionpack (4.2.5) lib/action_controller/metal/rendering.rb:16:in `render'
  actionpack (4.2.5) lib/action_controller/metal/instrumentation.rb:44:in `block (2 levels) in render'
  activesupport (4.2.5) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
  /home/ruby/.rbenv/versions/2.2.4/lib/ruby/2.2.0/benchmark.rb:303:in `realtime'
  activesupport (4.2.5) lib/active_support/core_ext/benchmark.rb:12:in `ms'
  actionpack (4.2.5) lib/action_controller/metal/instrumentation.rb:44:in `block in render'
  actionpack (4.2.5) lib/action_controller/metal/instrumentation.rb:87:in `cleanup_view_runtime'
  activerecord (4.2.5) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
  actionpack (4.2.5) lib/action_controller/metal/instrumentation.rb:43:in `render'
  admin/app/controllers/admin/application_controller.rb:302:in `loginpage'
  actionpack (4.2.5) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
  actionpack (4.2.5) lib/abstract_controller/base.rb:198:in `process_action'
  actionpack (4.2.5) lib/action_controller/metal/rendering.rb:10:in `process_action'
  actionpack (4.2.5) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
  activesupport (4.2.5) lib/active_support/callbacks.rb:117:in `call'
  activesupport (4.2.5) lib/active_support/callbacks.rb:117:in `call'
  activesupport (4.2.5) lib/active_support/callbacks.rb:555:in `block (2 levels) in compile'
  activesupport (4.2.5) lib/active_support/callbacks.rb:505:in `call'
  activesupport (4.2.5) lib/active_support/callbacks.rb:505:in `call'
  activesupport (4.2.5) lib/active_support/callbacks.rb:92:in `__run_callbacks__'
  activesupport (4.2.5) lib/active_support/callbacks.rb:778:in `_run_process_action_callbacks'
  activesupport (4.2.5) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (4.2.5) lib/abstract_controller/callbacks.rb:19:in `process_action'
  actionpack (4.2.5) lib/action_controller/metal/rescue.rb:29:in `process_action'
  actionpack (4.2.5) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
  activesupport (4.2.5) lib/active_support/notifications.rb:164:in `block in instrument'
  activesupport (4.2.5) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (4.2.5) lib/active_support/notifications.rb:164:in `instrument'
  actionpack (4.2.5) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
  actionpack (4.2.5) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
  activerecord (4.2.5) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
  actionpack (4.2.5) lib/abstract_controller/base.rb:137:in `process'
  actionview (4.2.5) lib/action_view/rendering.rb:30:in `process'
  actionpack (4.2.5) lib/action_controller/metal.rb:196:in `dispatch'
  actionpack (4.2.5) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
  actionpack (4.2.5) lib/action_controller/metal.rb:237:in `block in action'
  actionpack (4.2.5) lib/action_dispatch/routing/route_set.rb:76:in `call'
  actionpack (4.2.5) lib/action_dispatch/routing/route_set.rb:76:in `dispatch'
  actionpack (4.2.5) lib/action_dispatch/routing/route_set.rb:45:in `serve'
  actionpack (4.2.5) lib/action_dispatch/journey/router.rb:43:in `block in serve'
  actionpack (4.2.5) lib/action_dispatch/journey/router.rb:30:in `each'
  actionpack (4.2.5) lib/action_dispatch/journey/router.rb:30:in `serve'
  actionpack (4.2.5) lib/action_dispatch/routing/route_set.rb:817:in `call'
  railties (4.2.5) lib/rails/engine.rb:518:in `call'
  railties (4.2.5) lib/rails/railtie.rb:194:in `public_send'
  railties (4.2.5) lib/rails/railtie.rb:194:in `method_missing'
  actionpack (4.2.5) lib/action_dispatch/routing/mapper.rb:51:in `serve'
  actionpack (4.2.5) lib/action_dispatch/journey/router.rb:43:in `block in serve'
  actionpack (4.2.5) lib/action_dispatch/journey/router.rb:30:in `each'
  actionpack (4.2.5) lib/action_dispatch/journey/router.rb:30:in `serve'
  actionpack (4.2.5) lib/action_dispatch/routing/route_set.rb:817:in `call'
  rack (1.6.4) lib/rack/etag.rb:24:in `call'
  rack (1.6.4) lib/rack/conditionalget.rb:25:in `call'
  rack (1.6.4) lib/rack/head.rb:13:in `call'
  actionpack (4.2.5) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
  actionpack (4.2.5) lib/action_dispatch/middleware/flash.rb:260:in `call'
  rack (1.6.4) lib/rack/session/abstract/id.rb:225:in `context'
  rack (1.6.4) lib/rack/session/abstract/id.rb:220:in `call'
  actionpack (4.2.5) lib/action_dispatch/middleware/cookies.rb:560:in `call'
  activerecord (4.2.5) lib/active_record/query_cache.rb:36:in `call'
  activerecord (4.2.5) lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call'
  actionpack (4.2.5) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
  activesupport (4.2.5) lib/active_support/callbacks.rb:88:in `__run_callbacks__'
  activesupport (4.2.5) lib/active_support/callbacks.rb:778:in `_run_call_callbacks'
  activesupport (4.2.5) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (4.2.5) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (4.2.5) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
  actionpack (4.2.5) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
  actionpack (4.2.5) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.2.5) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.2.5) lib/rails/rack/logger.rb:20:in `block in call'
  activesupport (4.2.5) lib/active_support/tagged_logging.rb:68:in `block in tagged'
  activesupport (4.2.5) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (4.2.5) lib/active_support/tagged_logging.rb:68:in `tagged'
  railties (4.2.5) lib/rails/rack/logger.rb:20:in `call'
  actionpack (4.2.5) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
  rack (1.6.4) lib/rack/runtime.rb:18:in `call'
  activesupport (4.2.5) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
  rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
  railties (4.2.5) lib/rails/engine.rb:518:in `call'
  railties (4.2.5) lib/rails/application.rb:165:in `call'
  passenger (5.0.22) src/ruby_supportlib/phusion_passenger/rack/thread_handler_extension.rb:97:in `process_request'
  passenger (5.0.22) src/ruby_supportlib/phusion_passenger/request_handler/thread_handler.rb:152:in `accept_and_process_next_request'
  passenger (5.0.22) src/ruby_supportlib/phusion_passenger/request_handler/thread_handler.rb:113:in `main_loop'
  passenger (5.0.22) src/ruby_supportlib/phusion_passenger/request_handler.rb:416:in `block (3 levels) in start_threads'
  passenger (5.0.22) src/ruby_supportlib/phusion_passenger/utils.rb:113:in `block in create_thread_and_abort_on_exception'

Where TRUE ?

@rafaelfranca
Copy link
Member

This Parser error still looks like invalid JavaScript. I can't help more without knowing how to reproduce it.

@Sega100500
Copy link
Author

@rafaelfranca
I found a problem!!!
Thanks for point to target where I must look and find.
In assets directory was 2 same JS-libraries in different places.
Possibly it confict with 2 them.
But now all assets compiled at once in one heap. Even config.assets.compile = true
Early this work, but now must one exemplar.

Question

How I set several paths (or parts of path) to EXCLUDDE from precompile? It is possible?
For example:

Rails.application.config.assets.precompile += ['*.js', '*.css', '**/*.js', '**/*.css']

How exclude subdirectories src ?

@rafaelfranca
Copy link
Member

Yeah, just don't include them. BTW, *.js and *.css files are already in the precompile list by default.

@Sega100500
Copy link
Author

@rafaelfranca
And in subdirectories (any deep) too ?
'**/*.js', '**/*.css' not required too ?
Isn't possible exclude by mask for examle? All but without src/*.js, *src/*.js

@rafaelfranca
Copy link
Member

It is not. If you want more control I suggest you to use the new manifest feature https://github.com/rails/sprockets/blob/3.x/UPGRADING.md#preference-for-asset-manifest-and-links

@Sega100500
Copy link
Author

@rafaelfranca
Thanks for help!

@Sega100500
Copy link
Author

@rafaelfranca
Subjectively, but the system has become slower with sprockets-rails 3 and config.assets.compile = true
No perfomance test. Even visually noticeable that slower.
Compare identical two system:
with gem 'sprockets-rails', '< 3.0.0' in Gemfile it work faster.

@Sega100500
Copy link
Author

@rafaelfranca
Even users of sites have noticed a slowdown in the performance of sites.
Maybe you should change (reconstruct) some mechanisms in mode config.assets.compile = true for sprockets-rails 3.
To at least keep the performance at the same level sprockets-rails 2.

@Sega100500
Copy link
Author

@rafaelfranca
I guess that took place before the compilation occurred by request to a resource, and now compiles all at once before app start. Maybe turn back to previous mechanism?

@ebenenglish
Copy link

I know this issue is long closed, but I'm adding a comment for anyone who comes across this down the road (like I did).

Applies to sprockets-rails >=3.*.

If the image assets from your engine are not loading (despite what Rails says about "all non-JS/CSS in app/assets folder are already added"), and you're getting the "Asset was not declared to be precompiled in production" error, you need to add this to my_engine/lib/my_engine/engine.rb:

initializer 'my_engine.assets.precompile' do |app|
  app.config.assets.precompile += %w(my_engine/*.png my_engine/*.gif)
end

Or something along those lines, depending on how your image assets are structured.

@ghost
Copy link

ghost commented Jan 16, 2018

anyone can help me for this?
NoMethodError - undefined method `first' for #Sprockets::Asset:0x0000000c0cbd70

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

3 participants