the rails present not images declared asset ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.2 asset-pipeline precompile

ruby-on-rails - rails - the asset is not present in the asset pipeline



activos de rake: precompilar RAILS_ENV=la producción no funciona como se requiere (5)

¿Has añadido esta gema a tu gemfile?

# Use Uglifier as compressor for JavaScript assets gem ''uglifier'', ''>= 1.3.0''

mueva esa gema fuera del grupo de activos y luego ejecute Bundle nuevamente, ¡espero que eso ayude!

Estoy tratando de precompilar los activos usando el comando rake assets:precompile RAILS_ENV=production , pero siempre obtengo el error a continuación.

** Invoke assets:precompile (first_time) ** Execute assets:precompile /usr/bin/ruby /usr/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace ** Invoke assets:precompile:all (first_time) ** Execute assets:precompile:all ** Invoke assets:precompile:primary (first_time) ** Invoke assets:environment (first_time) ** Execute assets:environment ** Invoke environment (first_time) ** Execute environment ** Invoke tmp:cache:clear (first_time) ** Execute tmp:cache:clear ** Execute assets:precompile:primary rake aborted! LoadError: cannot load such file -- uglifier (in /home/cool_tech/cool_tech/app/assets/javascripts/application.js) /usr/lib/ruby/gems/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `require'' /usr/lib/ruby/gems/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `block in require'' /usr/lib/ruby/gems/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:236:in `load_dependency'' /usr/lib/ruby/gems/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `require'' /usr/lib/ruby/gems/2.0.0/gems/actionpack-3.2.14/lib/sprockets/compressors.rb:31:in `registered_js_compressor'' /usr/lib/ruby/gems/2.0.0/gems/actionpack-3.2.14/lib/sprockets/bootstrap.rb:18:in `block in run'' /usr/lib/ruby/gems/2.0.0/gems/actionpack-3.2.14/lib/sprockets/compressors.rb:80:in `call'' /usr/lib/ruby/gems/2.0.0/gems/actionpack-3.2.14/lib/sprockets/compressors.rb:80:in `compressor'' /usr/lib/ruby/gems/2.0.0/gems/actionpack-3.2.14/lib/sprockets/compressors.rb:74:in `compress'' /usr/lib/ruby/gems/2.0.0/gems/sprockets-2.2.2/lib/sprockets/processing.rb:265:in `block in js_compressor='' /usr/lib/ruby/gems/2.0.0/gems/sprockets-2.2.2/lib/sprockets/processor.rb:29:in `call'' /usr/lib/ruby/gems/2.0.0/gems/sprockets-2.2.2/lib/sprockets/processor.rb:29:in `evaluate'' /usr/lib/ruby/gems/2.0.0/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render'' /usr/lib/ruby/gems/2.0.0/gems/sprockets-2.2.2/lib/sprockets/context.rb:193:in `block in evaluate'' /usr/lib/ruby/gems/2.0.0/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in `each'' /usr/lib/ruby/gems/2.0.0/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in `evaluate'' /usr/lib/ruby/gems/2.0.0/gems/sprockets-2.2.2/lib/sprockets/bundled_asset.rb:26:in `initialize'' /usr/lib/ruby/gems/2.0.0/gems/sprockets-2.2.2/lib/sprockets/base.rb:252:in `new'' /usr/lib/ruby/gems/2.0.0/gems/sprockets-2.2.2/lib/sprockets/base.rb:252:in `build_asset'' /usr/lib/ruby/gems/2.0.0/gems/sprockets-2.2.2/lib/sprockets/index.rb:93:in `block in build_asset'' /usr/lib/ruby/gems/2.0.0/gems/sprockets-2.2.2/lib/sprockets/caching.rb:19:in `cache_asset'' /usr/lib/ruby/gems/2.0.0/gems/sprockets-2.2.2/lib/sprockets/index.rb:92:in `build_asset'' /usr/lib/ruby/gems/2.0.0/gems/sprockets-2.2.2/lib/sprockets/base.rb:169:in `find_asset'' /usr/lib/ruby/gems/2.0.0/gems/sprockets-2.2.2/lib/sprockets/index.rb:60:in `find_asset'' /usr/lib/ruby/gems/2.0.0/gems/actionpack-3.2.14/lib/sprockets/static_compiler.rb:19:in `block in compile'' /usr/lib/ruby/gems/2.0.0/gems/sprockets-2.2.2/lib/sprockets/base.rb:219:in `block in each_logical_path'' /usr/lib/ruby/gems/2.0.0/gems/sprockets-2.2.2/lib/sprockets/base.rb:206:in `block (2 levels) in each_file'' /usr/lib/ruby/gems/2.0.0/gems/sprockets-2.2.2/lib/sprockets/base.rb:196:in `each'' /usr/lib/ruby/gems/2.0.0/gems/sprockets-2.2.2/lib/sprockets/base.rb:196:in `each_entry'' /usr/lib/ruby/gems/2.0.0/gems/sprockets-2.2.2/lib/sprockets/base.rb:204:in `block in each_file'' /usr/lib/ruby/gems/2.0.0/gems/sprockets-2.2.2/lib/sprockets/base.rb:203:in `each'' /usr/lib/ruby/gems/2.0.0/gems/sprockets-2.2.2/lib/sprockets/base.rb:203:in `each_file'' /usr/lib/ruby/gems/2.0.0/gems/sprockets-2.2.2/lib/sprockets/base.rb:217:in `each_logical_path'' /usr/lib/ruby/gems/2.0.0/gems/actionpack-3.2.14/lib/sprockets/static_compiler.rb:18:in `compile'' /usr/lib/ruby/gems/2.0.0/gems/actionpack-3.2.14/lib/sprockets/assets.rake:56:in `internal_precompile'' /usr/lib/ruby/gems/2.0.0/gems/actionpack-3.2.14/lib/sprockets/assets.rake:70:in `block (3 levels) in <top (required)>'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/task.rb:240:in `call'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/task.rb:240:in `block in execute'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/task.rb:235:in `each'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/task.rb:235:in `execute'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'' /usr/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/task.rb:172:in `invoke_with_call_chain'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/task.rb:165:in `invoke'' /usr/lib/ruby/gems/2.0.0/gems/actionpack-3.2.14/lib/sprockets/assets.rake:60:in `block (3 levels) in <top (required)>'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/task.rb:240:in `call'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/task.rb:240:in `block in execute'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/task.rb:235:in `each'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/task.rb:235:in `execute'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'' /usr/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/task.rb:172:in `invoke_with_call_chain'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/task.rb:165:in `invoke'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/application.rb:150:in `invoke_task'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/application.rb:106:in `each'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/application.rb:106:in `block in top_level'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/application.rb:115:in `run_with_threads'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/application.rb:100:in `top_level'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/application.rb:78:in `block in run'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/application.rb:176:in `standard_exception_handling'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/application.rb:75:in `run'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/bin/rake:33:in `<top (required)>'' /usr/bin/rake:23:in `load'' /usr/bin/rake:23:in `<main>'' Tasks: TOP => assets:precompile:primary rake aborted! Command failed with status (1): [/usr/bin/ruby /usr/bin/rake assets:precomp...] /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/file_utils.rb:54:in `block in create_shell_runner'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/file_utils.rb:45:in `call'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/file_utils.rb:45:in `sh'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/file_utils_ext.rb:37:in `sh'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/file_utils.rb:82:in `ruby'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/file_utils_ext.rb:37:in `ruby'' /usr/lib/ruby/gems/2.0.0/gems/actionpack-3.2.14/lib/sprockets/assets.rake:12:in `ruby_rake_task'' /usr/lib/ruby/gems/2.0.0/gems/actionpack-3.2.14/lib/sprockets/assets.rake:21:in `invoke_or_reboot_rake_task'' /usr/lib/ruby/gems/2.0.0/gems/actionpack-3.2.14/lib/sprockets/assets.rake:29:in `block (2 levels) in <top (required)>'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/task.rb:240:in `call'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/task.rb:240:in `block in execute'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/task.rb:235:in `each'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/task.rb:235:in `execute'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'' /usr/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/task.rb:172:in `invoke_with_call_chain'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/task.rb:165:in `invoke'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/application.rb:150:in `invoke_task'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/application.rb:106:in `each'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/application.rb:106:in `block in top_level'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/application.rb:115:in `run_with_threads'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/application.rb:100:in `top_level'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/application.rb:78:in `block in run'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/application.rb:176:in `standard_exception_handling'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/lib/rake/application.rb:75:in `run'' /usr/lib/ruby/gems/2.0.0/gems/rake-10.2.2/bin/rake:33:in `<top (required)>'' /usr/bin/rake:23:in `load'' /usr/bin/rake:23:in `<main>'' Tasks: TOP => assets:precompile

¿Alguien tiene alguna idea de lo que podría estar mal? Gracias.


Descubrí que mi proyecto de copia de seguridad funcionó bien si compilo previamente sin la bundle update . Tal vez algo salió mal con la gema actualizada, pero no sé qué gema tiene un error.


Para explicar el problema, su error es el siguiente:

LoadError: cannot load such file -- uglifier (in /home/cool_tech/cool_tech/app/assets/javascripts/application.js)

Esto significa que en algún lugar de application.js , su aplicación hace referencia a uglifier (probablemente en el área de manifest en la parte superior del archivo). Para solucionar el problema, debe eliminar la referencia a uglifier o asegurarse de que el archivo uglifier esté presente en su aplicación, por lo tanto, las respuestas que se le proporcionaron

Fijar

Si no has tenido suerte al agregar la gema a tu GemFile, una solución rápida sería eliminar cualquier referencia a uglifier en tu manifiesto de application.js . Esto, por supuesto, será temporal, pero al menos le permitirá precompilar sus activos


Reemplazar

rake assets:precompile RAILS_ENV=production

con

rake assets:precompile ( RAILS_ENV=production bundle exec rake assets:precompile rake assets:precompile RAILS_ENV=production bundle exec rake assets:precompile es la tarea de rake exacta)

Dado que la precompilación se realiza solo en modo de producción, no es necesario especificar explícitamente el entorno.

Actualizar:

Intente agregar la siguiente línea a su Gemfile:

group :assets do gem ''therubyracer'' gem ''sass-rails'', " ~> 3.1.0" gem ''coffee-rails'', "~> 3.1.0" gem ''uglifier'' end

A continuación, ejecute bundle install .

Espero que funcione :)


Tuve este problema hoy. Lo arreglé siendo explícito sobre mi requerimiento

gem ''uglifier'', ''>= 1.0.3'', require: ''uglifier''

Yo tenía el mío todavía en el grupo de activos.