0

當我使用Capistrano的推到我的生產服務器我得到這個錯誤:Capistrano的資產預編譯錯誤

executing "cd /var/www/my_app/releases/20120731082050 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile" 
servers: ["my_app.com"] 
[my_app.com] executing command 
*** [err :: my_app.com] /usr/bin/ruby1.9.1 /var/www/my_app/shared/bundle/ruby/1.9.1/bin/rake assets:precompile:nondigest RAILS_ENV=production RAILS_GROUPS=assets 
*** [err :: my_app.com] 
command finished in 74149ms 

預編譯的工作,儘管錯誤。我試着運行

cd /var/www/my_app/releases/20120731082050 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile 

在服務器和它的作品,但它打印此控制檯:

/usr/bin/ruby1.9.1 /var/www/my_app/shared/bundle/ruby/1.9.1/bin/rake assets:precompile:nondigest RAILS_ENV=production RAILS_GROUPS=assets 

其中Capistrano的輸出相匹配(請注意,從原來的呼叫加入「nondigest」的?我知道,因爲它仍然有效它不是一個致命錯誤,但我會怎樣阻止它打印此錯誤

+0

嘗試把--trace在年底得到一個完整的堆棧跟蹤,即:CD /無功/網絡/ my_app應用/發佈/ 20120731082050 && bundle exec rake RAILS_ENV =生產RAILS_GROUPS =資產資產:預編譯 - 跟蹤 – 2012-07-31 09:58:35

回答

0

我只是overrided deploy:assets任務用我自己的代碼:

namespace :deploy 
    task :assets do 
    run "cd #{current_path} && bundle exec rake assets:precompile RAILS_ENV=#{rails_env}" 
    end 
end 
0

當您運行rake assets:precompile,如何避免違約輸出

的解決方案是添加-q behand你的命令

例如executing "cd /var/www/my_app/releases/20120731082050 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile -q"

分析如下,如果你想看到:

# :gem_path/actionpack/lib/sprockets/assets.rake 
namespace :assets do 

    # task entry, it will call invoke_or_reboot_rake_task 
    task :precompile do 
    invoke_or_reboot_rake_task "assets:precompile:all" 
    end 

    # it will call ruby_rake_task 
    def invoke_or_reboot_rake_task(task) 
    ruby_rake_task task 
    end 

    # it will call ruby 
    def ruby_rake_task(task, fork = true) 
    env = ENV['RAILS_ENV'] || 'production' 
    groups = ENV['RAILS_GROUPS'] || 'assets' 
    args = [$0, task,"RAILS_ENV=#{env}","RAILS_GROUPS=#{groups}"] 
    ruby(*args) 
    end 
end 

# :gem_path/rake/file_utils.rb 
module FileUtils 

    # it will call sh 
    def ruby(*args,&block) 
    options = (Hash === args.last) ? args.pop : {} 
    sh(*([RUBY] + args + [options]), &block) 
    end 

    # it will call set_verbose_option 
    # and if options[:verbose] == true, it do not output cmd 
    # but default of options[:verbose] is an object 
    def sh(*cmd, &block) 
    # ... 
    set_verbose_option(options) 
    # ... 
    Rake.rake_output_message cmd.join(" ") if options[:verbose] 
    # ... 
    end 

    # default of options[:verbose] is Rake::FileUtilsExt::DEFAULT, which is an object 
    def set_verbose_option(options) # :nodoc: 
    unless options.key? :verbose 
     options[:verbose] = 
     Rake::FileUtilsExt.verbose_flag == Rake::FileUtilsExt::DEFAULT || 
     Rake::FileUtilsExt.verbose_flag 
    end 
    end 
end 

# :gem_path/rake/file_utils_ext.rb 
module Rake 
    module FileUtilsExt 
    DEFAULT = Object.new 
    end 
end 

# :gem_path/rake/application.rb 
      # the only to solve the disgusting output when run `rake assets:precompile` 
      # is add a `-q` option. 
      ['--quiet', '-q', 
      "Do not log messages to standard output.", 
      lambda { |value| Rake.verbose(false) } 
      ], 
      ['--verbose', '-v', 
      "Log message to standard output.", 
      lambda { |value| Rake.verbose(true) } 
      ],