sprockets-rails: Fail to run rails app 4.2.5 with sprockets-rails 3.0.0

https://github.com/rails/rails/issues/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!

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 52 (15 by maintainers)

Most upvoted comments

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.

@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>'