我使用命令
执行资产预编译rakebundle exec rake assets:precompile --trace
在远程服务器(ec2 ubuntu)中的rails应用程序(生产环境)上。 由于鬼的原因,预编译失败了。我尝试了很多可能的解决方案,但仍然无法预编译。下面是log和gemfile
LOG
ubuntu@ip-000-00-00-000:~/testproject$ bundle exec rake assets:precompile
--trace --verbose
** Invoke assets:precompile (first_time)
** Execute assets:precompile
/home/ubuntu/.rvm/rubies/ruby-1.9.3-p448/bin/ruby /home/ubuntu/.rvm/gems/ruby-1.9.3-p448/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
Compiled jquery.js (0ms) (pid 27961)
Compiled jquery_ujs.js (0ms) (pid 27961)
Compiled jquery-ui.js (441ms) (pid 27961)
Compiled bootstrap.js (72ms) (pid 27961)
Compiled jquery.jscrollpane.min.js (0ms) (pid 27961)
Compiled jquery.mousewheel.js (0ms) (pid 27961)
Compiled shared.js (0ms) (pid 27961)
Compiled highcharts.js (2ms) (pid 27961)
Compiled application.js (1471ms) (pid 27961)
Compiled bbcreate.js (0ms) (pid 27961)
Compiled bbedit.js (0ms) (pid 27961)
Compiled console.js (0ms) (pid 27961)
Compiled documentcreate.js (0ms) (pid 27961)
Compiled documentedit.js (0ms) (pid 27961)
Compiled documentfind.js (379ms) (pid 27961)
Compiled reportcreate.js (0ms) (pid 27961)
Compiled reportedit.js (2ms) (pid 27961)
Compiled bootstrap.css (295ms) (pid 27961)
Compiled bootstrap-responsive.css (0ms) (pid 27961)
Compiled jquery.jscrollpane.css (0ms) (pid 27961)
Compiled jquery-ui.css (27ms) (pid 27961)
Compiled shared.css (1161ms) (pid 27961)
Compiled application.css (1615ms) (pid 27961)
Compiled authentication.css (8ms) (pid 27961)
Compiled bbcreate.css (6ms) (pid 27961)
Compiled bbedit.css (136ms) (pid 27961)
Compiled console.css (32ms) (pid 27961)
Compiled documentcreate.css (61ms) (pid 27961)
Compiled documentedit.css (62ms) (pid 27961)
Compiled documentfind.css (86ms) (pid 27961)
Compiled reportcreate.css (6ms) (pid 27961)
Compiled reportedit.css (205ms) (pid 27961)
Compiled viewHTML.css (19ms) (pid 27961)
Compiled viewPDF.css (19ms) (pid 27961)
** Invoke assets:precompile:nondigest (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:nondigest
Compiled jquery.js (1ms) (pid 27961)
Compiled jquery_ujs.js (0ms) (pid 27961)
Compiled jquery-ui.js (42ms) (pid 27961)
Compiled bootstrap.js (0ms) (pid 27961)
Compiled jquery.jscrollpane.min.js (0ms) (pid 27961)
Compiled jquery.mousewheel.js (0ms) (pid 27961)
Compiled shared.js (0ms) (pid 27961)
Compiled highcharts.js (2ms) (pid 27961)
Compiled application.js (1276ms) (pid 27961)
Compiled bbcreate.js (0ms) (pid 27961)
Compiled bbedit.js (0ms) (pid 27961)
Compiled console.js (0ms) (pid 27961)
Compiled documentcreate.js (0ms) (pid 27961)
Compiled documentedit.js (1ms) (pid 27961)
Compiled documentfind.js (0ms) (pid 27961)
Compiled reportcreate.js (0ms) (pid 27961)
Compiled reportedit.js (2ms) (pid 27961)
Compiled bootstrap.css (217ms) (pid 27961)
Compiled bootstrap-responsive.css (0ms) (pid 27961)
Compiled jquery.jscrollpane.css (0ms) (pid 27961)
Compiled jquery-ui.css (24ms) (pid 27961)
Compiled shared.css (323ms) (pid 27961)
Compiled application.css (655ms) (pid 27961)
rake aborted!
Command failed with status (): [/home/ubuntu/.rvm/rubies/ruby-1.9.3-p448/b...]
/home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/rake-10.1.1/lib/rake/file_utils.rb:55:in `block in create_shell_runner'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/rake-10.1.1/lib/rake/file_utils.rb:45:in `call'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/rake-10.1.1/lib/rake/file_utils.rb:45:in `sh'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/rake-10.1.1/lib/rake/file_utils_ext.rb:37:in `sh'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/rake-10.1.1/lib/rake/file_utils.rb:82:in `ruby'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/rake-10.1.1/lib/rake/file_utils_ext.rb:37:in `ruby'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/actionpack-3.2.12/lib/sprockets/assets.rake:12:in `ruby_rake_task'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/actionpack-3.2.12/lib/sprockets/assets.rake:21:in `invoke_or_reboot_rake_task'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/actionpack-3.2.12/lib/sprockets/assets.rake:29:in `block (2 levels) in <top (required)>'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/rake-10.1.1/lib/rake/task.rb:236:in `call'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/rake-10.1.1/lib/rake/task.rb:236:in `block in execute'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/rake-10.1.1/lib/rake/task.rb:231:in `each'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/rake-10.1.1/lib/rake/task.rb:231:in `execute'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/rake-10.1.1/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/home/ubuntu/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/rake-10.1.1/lib/rake/task.rb:168:in `invoke_with_call_chain'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/rake-10.1.1/lib/rake/task.rb:161:in `invoke'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/rake-10.1.1/lib/rake/application.rb:149:in `invoke_task'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/rake-10.1.1/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/rake-10.1.1/lib/rake/application.rb:106:in `each'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/rake-10.1.1/lib/rake/application.rb:106:in `block in top_level'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/rake-10.1.1/lib/rake/application.rb:115:in `run_with_threads'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/rake-10.1.1/lib/rake/application.rb:100:in `top_level'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/rake-10.1.1/lib/rake/application.rb:78:in `block in run'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/rake-10.1.1/lib/rake/application.rb:165:in `standard_exception_handling'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/rake-10.1.1/lib/rake/application.rb:75:in `run'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/rake-10.1.1/bin/rake:33:in `<top (required)>'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p448/bin/rake:19:in `load'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p448/bin/rake:19:in `<main>'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p448/bin/ruby_noexec_wrapper:14:in `eval'
/home/ubuntu/.rvm/gems/ruby-1.9.3-p448/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => assets:precompile
的Gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.12'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'geoip'
gem 'therubyracer', :platform => :ruby
gem 'sqlite3'
gem "mongoid", "~> 3.1.6"
gem "bson_ext", "~> 1.4"
gem "htmlentities", "~> 4.3.1"
gem 'geo_ip'
gem "mongoid-paperclip", :require => "mongoid_paperclip"
gem 'execjs'
gem 'wkhtmltopdf-binary'
gem 'wicked_pdf'
#gem 'libv8'
#gem 'therubyracer'
#gem "therubyracer", :require => 'v8'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
#gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'debugger'
我很乐意得到一些帮助。谢谢。
附加信息
我没有把所有内容都放在application.css和appplication.js中,而是每个控制器包含资产,因此我需要将这些行放在我的production.rb中
config.assets.precompile += ['authentication.css']
config.assets.precompile += ['bbcreate.css']
config.assets.precompile += ['bbedit.css']
config.assets.precompile += ['console.css']
config.assets.precompile += ['documentcreate.css']
config.assets.precompile += ['documentedit.css']
config.assets.precompile += ['documentfind.css']
config.assets.precompile += ['reportcreate.css']
config.assets.precompile += ['reportedit.css']
config.assets.precompile += ['viewHTML.css']
config.assets.precompile += ['viewPDF.css']
config.assets.precompile += ['authentication.js']
config.assets.precompile += ['bbcreate.js']
config.assets.precompile += ['bbedit.js']
config.assets.precompile += ['console.js']
config.assets.precompile += ['documentcreate.js']
config.assets.precompile += ['documentedit.js']
config.assets.precompile += ['documentfind.js']
config.assets.precompile += ['reportcreate.js']
config.assets.precompile += ['reportedit.js']
这是我的application.js
//= require jquery
//= require jquery_ujs
//= require jquery-ui
//= require bootstrap
//= require jquery.jscrollpane.min
//= require jquery.mousewheel
//= require shared
//= require highcharts
和application.css
*= require_self
*= require bootstrap
*= require bootstrap-responsive
*= require jquery.jscrollpane
*= require jquery-ui
*= require shared
运行rake assets:precompile:primary
没有错误。运行rake assets:precompile:all
或rake assets:precompile:nondigest
也是如此。但是,单独运行这些进程只能成功编译我的映像,application.css和application.js。通过production.rb配置包含的其他js和css不能编译。当我运行rake assets:precompile --trace
时,它编译所有js n css,甚至包括来自production.rb config的那些(因为它是--trace,它显示它正在编译每个文件),但它总是因为错误。