我正在测试RoR 4.2.x应用程序的部署......
当我在开发中执行它时运行良好, 如果我模拟vm上的部署以准备最终部署阶段, 我在资产预编译期间收到错误....
部署环境是使用rvm,passenger和Apache作为Web服务器的ubuntu 14.04 lts服务器..
在完成所有需要的库更新(作为先决条件)之后,我已经将工作目录的repo签出到Web服务器上, 然后在工作目录中正确执行'bundle update'以正确填充gemset ......
在此阶段没有从服务器控制台返回错误,所有似乎都运行良好......
如果我运行“宝石列表”所有需要的宝石结果存在
现在,使用以下命令预编译资产:
RAILS_ENV=production bundle exec rake assets:precompile
操作在几秒钟后因此错误而中止:
rake aborted!
Sprockets::FileNotFound: couldn't find file 'jquery-ui' with type 'application/javascript'
/home/rails-usr/www_v2/app/assets/javascripts/application.js:10
/home/rails-usr/.rvm/gems/ruby-2.2.2@Best-i-gest_v2/gems/sprockets-3.6.2/lib/sprockets/resolve.rb:64:in `resolve!'
/home/rails-usr/.rvm/gems/ruby-2.2.2@Best-i-gest_v2/gems/sprockets-3.6.2/lib/sprockets/directive_processor.rb:399:in `resolve'
/home/rails-usr/.rvm/gems/ruby-2.2.2@Best-i-gest_v2/gems/sprockets-3.6.2/lib/sprockets/directive_processor.rb:207:in `process_require_directive'
.....
要在我的问题中添加更多信息......
这是我的应用'Gemfile'
source 'http://rubygems.org'
gem 'rails', '4.2.5'
gem 'mysql2', '0.3.17'
gem 'bcrypt-ruby', :require => 'bcrypt'
gem 'declarative_authorization', :git => 'git://github.com/stffn/declarative_authorization'
gem 'ruby_parser'
gem 'jQuery-Validation-Engine-rails'
gem 'prawn', '1.3.0'
gem 'prawn-table', '0.2.1'
# gem 'bootstrap-sass', '~> 3.1.1'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails'
gem 'coffee-rails'
gem 'uglifier'
gem "therubyracer"
gem "less-rails", :git => 'git://github.com/metaskills/less-rails', :ref => '539f28d'
gem 'jquery-datatables-rails' , :git => 'git://github.com/rweng/jquery-datatables-rails'
gem 'jquery-ui-rails'
end
gem 'twitter-bootstrap-rails', :git => 'git://github.com/coppolaf/tb3-rails4.git'
gem 'jquery-rails'
gem 'will_paginate'
gem 'nokogiri'
# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'
group :test do
# Pretty printed test output
gem 'turn', '~> 0.8.3', :require => false
end
这是'application.js'文件:
// This is a manifest file that'll be compiled into including all the files listed below.
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
// be included in the compiled file accessible from http://example.com/assets/application.js
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
//= require jquery
//= require jquery-ui
//= require jquery_ujs
//= require dataTables/jquery.dataTables
//= require twitter/bootstrap
//= require jquery.validationEngine
//= require_tree .
....
这是'application.css'文件:
/*
* This is a manifest file that'll automatically include all the stylesheets available in this directory
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
* the top of the compiled file, but it's generally better to create a new file per style scope.
*= require_self
*= require jquery-ui
*= require dataTables/src/demo_table_jui
*= bootstrap_and_overrides.css.less
*= require validationEngine.jquery
*= require_tree .
*/
....
请注意所有jquery模块在开发中运行良好,请求的模块似乎存在于gemset内....
等待你的建议,
的问候, 弗朗西斯科
答案 0 :(得分:0)
根据您发布的链接错误,我预计application.js
//= require jquery-ui
<强>加强>
您的其他信息很有帮助。 您的application.css不应包含jquery-ui ,这不是css,会抛出与您所看到的一致的链接错误。我会减少你的application.css只包括css类型的资产。
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require_tree .
*= bootstrap_and_overrides.css.less
*= any other css, scss, etc
*= require_self
*/
让我知道这是怎么回事。
建议的测试
我刚注意到dev和prod之间存在差异。在你的jquery-ui设置中。这是一项重要的测试,因为它是您看到的资产负载问题。这就是你所拥有的:
group :assets do
gem 'sass-rails'
gem 'coffee-rails'
gem 'uglifier'
gem "therubyracer"
gem "less-rails", :git => 'git://github.com/metaskills/less-rails', :ref => '539f28d'
gem 'jquery-datatables-rails' , :git => 'git://github.com/rweng/jquery-datatables-rails'
gem 'jquery-ui-rails'
end
尝试在Gemfile中移动资产组外的gem ,如下所示$bundle install
并测试:
gem 'jquery-rails'
gem 'jquery-ui-rails'
让我知道会发生什么
答案 1 :(得分:0)
感谢Wishalizer的建议,我终于解决了这个问题...
错误与Gemfile结构有关....我已将其修改如下......
文件:&#39; Gemfile&#39;
source 'http://rubygems.org'
gem 'rails', '4.2.5'
gem 'mysql2', '0.3.17'
gem 'bcrypt-ruby', :require => 'bcrypt'
gem 'declarative_authorization', :git => 'git://github.com/stffn/declarative_authorization'
gem 'ruby_parser'
gem 'jQuery-Validation-Engine-rails'
gem 'prawn', '1.3.0'
gem 'prawn-table', '0.2.1'
# gem 'bootstrap-sass', '~> 3.1.1'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails'
gem 'coffee-rails'
gem 'uglifier'
gem "therubyracer"
gem "less-rails", :git => 'git://github.com/metaskills/less-rails', :ref => '539f28d'
end
gem 'twitter-bootstrap-rails', :git => 'git://github.com/coppolaf/tb3-rails4.git'
gem 'jquery-rails'
gem 'jquery-ui-rails'
gem 'jquery-datatables-rails' , :git => 'git://github.com/rweng/jquery-datatables-rails'
gem 'will_paginate'
gem 'nokogiri'
# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'
group :test do
# Pretty printed test output
gem 'turn', '~> 0.8.3', :require => false
end
将引用移到资产部分之外的jquery-ui-rails和jquery-datatables-rails ... 使资产预编译任务能够完成而不会出现错误!!
希望这会有所帮助......
再见 弗朗西斯科