ruby rails 3.2 rake assets:precompile fails for engine assets -


i've created full engine packaged gem allows me deploy css, images, js/jquery items , working user model common of projects. in development mode, works smartly. however, trying precompile assets use in production throws error:

# rails_env=production bundle exec rake assets:precompile /usr/local/bin/ruby /usr/local/bin/rake assets:precompile:all rails_env=production  rails_groups=assets rake aborted! couldn't find file 'my_stock.engine'   (in my_example_app/app/assets/javascripts/application.js:17)  tasks: top => assets:precompile:primary (see full trace running task --trace) rake aborted! command failed status (1): [/usr/local/bin/ruby /usr/local/bin/rake as...]  tasks: top => assets:precompile (see full trace running task --trace) 

i've spent bit of time throwing web searches @ problem, have not found related. expect i've forgotten in setting 'my_stock.engine' or in my_example_app, since first time i've tried this.

edit: adding --trace results

** invoke assets:precompile (first_time) ** execute assets:precompile /usr/local/bin/ruby /usr/local/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! couldn't find file 'my_stock.engine'   (in /opt/bv_applets/meetme_manager/app/assets/javascripts/application.js:17) /usr/local/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/context.rb:102:in `resolve' /usr/local/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/context.rb:142:in `require_asset' /usr/local/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/directive_processor.rb:215:in `process_require_directive' /usr/local/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/directive_processor.rb:165:in `block in process_directives' /usr/local/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/directive_processor.rb:163:in `each' /usr/local/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/directive_processor.rb:163:in `process_directives' /usr/local/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/directive_processor.rb:97:in `evaluate' /usr/local/lib/ruby/gems/1.9.1/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render' /usr/local/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/context.rb:193:in `block in evaluate' /usr/local/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in `each' /usr/local/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in `evaluate' /usr/local/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/processed_asset.rb:12:in `initialize' /usr/local/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:249:in `new' /usr/local/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:249:in `block in build_asset' /usr/local/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:270:in `circular_call_protection' /usr/local/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:248:in `build_asset' /usr/local/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/index.rb:93:in `block in build_asset' /usr/local/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/caching.rb:19:in `cache_asset' /usr/local/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/index.rb:92:in `build_asset' /usr/local/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:169:in `find_asset' /usr/local/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/index.rb:60:in `find_asset' /usr/local/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/bundled_asset.rb:16:in `initialize' /usr/local/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:252:in `new' /usr/local/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:252:in `build_asset' /usr/local/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/index.rb:93:in `block in build_asset' /usr/local/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/caching.rb:19:in `cache_asset' /usr/local/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/index.rb:92:in `build_asset' /usr/local/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:169:in `find_asset' /usr/local/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/index.rb:60:in `find_asset' /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.2.13/lib/sprockets/static_compiler.rb:19:in `block in compile' /usr/local/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:219:in `block in each_logical_path' /usr/local/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:206:in `block (2 levels) in each_file' /usr/local/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:196:in `each' /usr/local/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:196:in `each_entry' /usr/local/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:204:in `block in each_file' /usr/local/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:203:in `each' /usr/local/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:203:in `each_file' /usr/local/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:217:in `each_logical_path' /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.2.13/lib/sprockets/static_compiler.rb:18:in `compile' /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.2.13/lib/sprockets/assets.rake:56:in `internal_precompile' /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.2.13/lib/sprockets/assets.rake:70:in `block (3 levels) in <top (required)>' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:236:in `call' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:231:in `each' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain' /usr/local/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke' /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.2.13/lib/sprockets/assets.rake:60:in `block (3 levels) in <top (required)>' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:236:in `call' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:231:in `each' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain' /usr/local/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:149:in `invoke_task' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:106:in `block (2 levels) in top_level' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:106:in `each' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:106:in `block in top_level' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:115:in `run_with_threads' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:100:in `top_level' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:78:in `block in run' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:75:in `run' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/bin/rake:33:in `<top (required)>' /usr/local/bin/rake:23:in `load' /usr/local/bin/rake:23:in `<main>' tasks: top => assets:precompile:primary rake aborted! command failed status (1): [/usr/local/bin/ruby /usr/local/bin/rake as...] /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/file_utils.rb:55:in `block in create_shell_runner' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/file_utils.rb:45:in `call' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/file_utils.rb:45:in `sh' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/file_utils_ext.rb:37:in `sh' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/file_utils.rb:82:in `ruby' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/file_utils_ext.rb:37:in `ruby' /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.2.13/lib/sprockets/assets.rake:12:in `ruby_rake_task' /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.2.13/lib/sprockets/assets.rake:21:in `invoke_or_reboot_rake_task' /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.2.13/lib/sprockets/assets.rake:29:in `block (2 levels) in <top (required)>' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:236:in `call' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:231:in `each' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain' /usr/local/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:149:in `invoke_task' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:106:in `block (2 levels) in top_level' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:106:in `each' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:106:in `block in top_level' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:115:in `run_with_threads' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:100:in `top_level' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:78:in `block in run' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:75:in `run' /usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/bin/rake:33:in `<top (required)>' /usr/local/bin/rake:23:in `load' /usr/local/bin/rake:23:in `<main>' tasks: top => assets:precompile 

/edit

edit2: further digging , review of error , configs:

my_example_app/app/assets/javascripts/application.js

13: //= require jquery 14: //= require jquery_ujs 15: //= require jquery.ui.datepicker 16: //= require_tree . 17: //= require my_stock.engine 

the rails asset pipeline config path:

$ rails c   ------ loading development environment (rails 3.2.13) 1.9.3-p392 :001 > y rails.application.config.assets.paths --- - /my_example_app/app/assets/images - /my_example_app/app/assets/javascripts - /my_example_app/app/assets/stylesheets - /my_example_app/vendor/assets/javascripts - /my_example_app/vendor/assets/stylesheets - /.rvm/gems/ruby-1.9.3-p392/gems/jquery-rails-3.0.4/vendor/assets/javascripts - /.rvm/gems/ruby-1.9.3-p392/gems/jquery-ui-rails-4.0.3/app/assets/images - /.rvm/gems/ruby-1.9.3-p392/gems/jquery-ui-rails-4.0.3/app/assets/javascripts - /.rvm/gems/ruby-1.9.3-p392/gems/jquery-ui-rails-4.0.3/app/assets/stylesheets - /.rvm/gems/ruby-1.9.3-p392/gems/twitter-bootstrap-rails-2.2.7/app/assets/fonts - /.rvm/gems/ruby-1.9.3-p392/gems/twitter-bootstrap-rails-2.2.7/app/assets/images - /.rvm/gems/ruby-1.9.3-p392/gems/twitter-bootstrap-rails-2.2.7/app/assets/javascripts - /.rvm/gems/ruby-1.9.3-p392/gems/twitter-bootstrap-rails-2.2.7/app/assets/stylesheets - /.rvm/gems/ruby-1.9.3-p392/gems/coffee-rails-3.2.2/lib/assets/javascripts - /.rvm/gems/ruby-1.9.3-p392/gems/bootstrap-sass-2.3.2.1/vendor/assets/images - /.rvm/gems/ruby-1.9.3-p392/gems/bootstrap-sass-2.3.2.1/vendor/assets/javascripts - /.rvm/gems/ruby-1.9.3-p392/gems/bootstrap-sass-2.3.2.1/vendor/assets/stylesheets - /my_stock.engine/app/assets/images - /my_stock.engine/app/assets/javascripts - /my_stock.engine/app/assets/stylesheets  => nil 1.9.3-p392 :002 > exit 

... "my_stock.engine" in assets path.

/edit2

thanks in advance / & suggestions!

theres few questions need ask yourself. whether have set engine correctly. have not dabbled setting rails engine myself having read ruby on rails guide: adding assets gems. highlights:

this gem contains engine class inherits rails::engine. doing this, rails informed directory gem may contain assets , app/assets, lib/assets , vendor/assets directories of engine added search path of sprockets.

you can see yourself: jquery-rails. understanding of quote above tells making making engine class inherit rails engine should inherit rails methods along , says inform directory can contain assets.

further thing need take account when precompiling stated that:

for faster asset precompiles, can partially load application setting config.assets.initialize_on_precompile false in config/application.rb, though in case templates cannot see application objects or methods. heroku requires false.

another warning puts forward following think happening you:

if set config.assets.initialize_on_precompile false, sure test rake assets:precompile locally before deploying. may expose bugs assets reference application objects or methods, since still in scope in development mode regardless of value of flag. changing flag affects engines. engines can define assets precompilation well. since complete environment not loaded, engines (or other gems) not loaded, can cause missing assets.

you can see here in above quote 1) having set false may cause bugs should test locally. further points out affects engines.

main part

engines can define assets precompilation well. since complete environment not loaded, engines (or other gems) not loaded, can cause missing assets.

so in saying of believe if have config.assets.intialize_on_precompile set false app not being started. hope helps out sure learned well.

updated answer

dependent on how including engine in application important specify path correctly. error message trace indicates may not located in application. please check if have my_stock_engine.js in either of paths

app/assets/javascript/my_stock_engine.js app/vendor/assets/javascript/my_stock_engine.js app/lib/assets/my_stock_engine.js my_stock_engine/app/assets/javascript/my_stock_engine.js 

in gemfile depneds on how have added via path: '/some/path'


Comments