rake assets:precompile 突然失败
Posted
技术标签:
【中文标题】rake assets:precompile 突然失败【英文标题】:rake assets:precompile fails all of a sudden 【发布时间】:2014-07-08 12:35:48 【问题描述】:我对我的暂存 Rails 应用程序进行了更改。我交换了一个标题图像,因此想再次预编译资产。上周五它还在工作,现在在这个微小的变化之后它突然失败了。我使用部署脚本执行此操作,该脚本克隆 git 存储库,然后调用 bundle install 和 rake 任务进行预编译,然后将文件夹移动到 /var/www。手动调用webserver目录下的预编译任务也会出现同样的错误。
配置是:
Ubuntu 12.04, nginx 1.4.7, 红宝石 1.9.3, 轨道 4.0.2
我得到的错误:
ubuntu@ip-xx-xxx-xx-xxx:/var/www/myproject-web$ RAILS_ENV=staging bundle exec rake --trace assets:precompile
** Invoke assets:precompile (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Execute assets:precompile
rake aborted!
Sprockets::FileNotFound: couldn't find file 'jquery.ui.tabs'
(in /var/www/myproject-web/app/assets/javascripts/application.js:15)
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sprockets-2.11.0/lib/sprockets/context.rb:106:in `resolve'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sprockets-2.11.0/lib/sprockets/context.rb:146:in `require_asset'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sprockets-2.11.0/lib/sprockets/directive_processor.rb:217:in `process_require_directive'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sprockets-2.11.0/lib/sprockets/directive_processor.rb:167:in `block in process_directives'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sprockets-2.11.0/lib/sprockets/directive_processor.rb:165:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sprockets-2.11.0/lib/sprockets/directive_processor.rb:165:in `process_directives'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sprockets-2.11.0/lib/sprockets/directive_processor.rb:99:in `evaluate'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sprockets-2.11.0/lib/sprockets/context.rb:197:in `block in evaluate'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sprockets-2.11.0/lib/sprockets/context.rb:194:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sprockets-2.11.0/lib/sprockets/context.rb:194:in `evaluate'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sprockets-2.11.0/lib/sprockets/processed_asset.rb:12:in `initialize'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sprockets-2.11.0/lib/sprockets/base.rb:374:in `new'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sprockets-2.11.0/lib/sprockets/base.rb:374:in `block in build_asset'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sprockets-2.11.0/lib/sprockets/base.rb:395:in `circular_call_protection'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sprockets-2.11.0/lib/sprockets/base.rb:373:in `build_asset'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sprockets-2.11.0/lib/sprockets/index.rb:94:in `block in build_asset'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sprockets-2.11.0/lib/sprockets/caching.rb:58:in `cache_asset'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sprockets-2.11.0/lib/sprockets/index.rb:93:in `build_asset'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sprockets-2.11.0/lib/sprockets/base.rb:287:in `find_asset'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sprockets-2.11.0/lib/sprockets/index.rb:61:in `find_asset'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sprockets-2.11.0/lib/sprockets/bundled_asset.rb:16:in `initialize'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sprockets-2.11.0/lib/sprockets/base.rb:377:in `new'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sprockets-2.11.0/lib/sprockets/base.rb:377:in `build_asset'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sprockets-2.11.0/lib/sprockets/index.rb:94:in `block in build_asset'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sprockets-2.11.0/lib/sprockets/caching.rb:58:in `cache_asset'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sprockets-2.11.0/lib/sprockets/index.rb:93:in `build_asset'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sprockets-2.11.0/lib/sprockets/base.rb:287:in `find_asset'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sprockets-2.11.0/lib/sprockets/index.rb:61:in `find_asset'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:211:in `block in find_asset'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:257:in `benchmark'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:210:in `find_asset'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:119:in `block in compile'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:118:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:118:in `compile'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sprockets-rails-2.0.1/lib/sprockets/rails/task.rb:60:in `block (3 levels) in define'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sprockets-2.11.0/lib/rake/sprocketstask.rb:146:in `with_logger'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sprockets-rails-2.0.1/lib/sprockets/rails/task.rb:59:in `block (2 levels) in define'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/rake-10.3.2/lib/rake/task.rb:240:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/rake-10.3.2/lib/rake/task.rb:240:in `block in execute'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/rake-10.3.2/lib/rake/task.rb:235:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/rake-10.3.2/lib/rake/task.rb:235:in `execute'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/rake-10.3.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/local/rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/rake-10.3.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/rake-10.3.2/lib/rake/task.rb:165:in `invoke'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/rake-10.3.2/lib/rake/application.rb:150:in `invoke_task'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/rake-10.3.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/rake-10.3.2/lib/rake/application.rb:106:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/rake-10.3.2/lib/rake/application.rb:106:in `block in top_level'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/rake-10.3.2/lib/rake/application.rb:115:in `run_with_threads'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/rake-10.3.2/lib/rake/application.rb:100:in `top_level'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/rake-10.3.2/lib/rake/application.rb:78:in `block in run'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/rake-10.3.2/lib/rake/application.rb:176:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/rake-10.3.2/lib/rake/application.rb:75:in `run'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/rake-10.3.2/bin/rake:33:in `<top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p484/bin/rake:23:in `load'
/usr/local/rvm/gems/ruby-1.9.3-p484/bin/rake:23:in `<main>'
/usr/local/rvm/gems/ruby-1.9.3-p484/bin/ruby_executable_hooks:15:in `eval'
/usr/local/rvm/gems/ruby-1.9.3-p484/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => assets:precompile
自上次成功预编译后,我的 application.js 中没有任何更改
//= require jquery
//= require jquery_ujs
//= require jquery.ui.tabs
//= require jquery.ui.dialog
//= require knockout-3.0.0
//= require jquery.jplayer.min
//= require_tree .
Gemfile 也没有被触及。
gem 'rails', '4.0.2'
gem 'pg'
gem 'sass-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'jquery-ui-rails'
gem 'jbuilder', '~> 1.2'
group :doc do
gem 'sdoc', require: false
end
gem 'bcrypt-ruby', '~> 3.1.2'
gem 'right_aws'
gem 'devise'
gem 'devise_invitable'
gem 'cancan'
gem 'will_paginate'
gem 'asset_sync'
gem 'unf'
gem 'koala', '~> 1.10.0rc'
gem 'httparty'
有没有人经历过同样的行为?什么可能导致此错误?
【问题讨论】:
【参考方案1】:Jquery ui 前几天改变了它的包含方式
在application.js中改成:
//= require jquery-ui/dialog
//= require jquery-ui/tabs
如果你需要 css
*= require jquery-ui/dialog
*= require jquery-ui/tabs
【讨论】:
请解释你的答案。 @Зелёный//= jquery.ui.tabs
不再需要它,他们更改了 jquery-ui-rails 中调用 js 文件的内容
您先生值得尊重!
@CPlusPlusNewbie 我昨天遇到了同样的问题。
@CPlusPlusNewbie 好吧,因为错误在jquery-ui-rails
我想我会检查documentation以上是关于rake assets:precompile 突然失败的主要内容,如果未能解决你的问题,请参考以下文章
rake assets:precompile 试图连接到生产数据库?
Rake assets:precompile 在生产中打开控制台会话时被终止
在 bundle exec rake assets:precompile 后 OpsWorks 部署失败
Capistrano - rake assets:precompile - 应用程序已经初始化