2012-02-08 34 views
8

My App dường như được triển khai một cách chính xác nhưng tôi nhận được lỗi này:Lỗi nội dung biên dịch của Capistrano - tài sản: biên dịch trước: nondigest?

 * executing "cd /home/deploy/tomahawk/releases/20120208222225 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile" 
    servers: ["ip_address"] 
    [ip_address] executing command 
*** [err :: ip_address] /opt/ruby/bin/ruby /opt/ruby/bin/rake assets:precompile:nondigest RAILS_ENV=production RAILS_GROUPS=assets 

Tôi đã thử các giải pháp vào đây để cố gắng để biên dịch tài sản: http://lassebunk.dk/2011/09/03/getting-your-assets-to-work-when-upgrading-to-rails-3-1/

Và đây: http://railsmonkey.net/2011/08/deploying-rails-3-1-applications-with-capistrano/

Và tại đây: http://dev.af83.com/2011/09/30/capistrano-rails-3-1-assets-can-be-tricky.html

Đây là triển khai của tôi.rb:

require "bundler/capistrano" 
load 'deploy/assets' 

set :default_environment, { 
'PATH' => "/opt/ruby/bin/:$PATH" 
} 

set :application, "tomahawk" 
set :repository, "repo_goes_here" 
set :deploy_to, "/home/deploy/#{application}" 
set :rails_env, 'production' 
set :branch, "master" 

set :scm, :git 
set :user, "deploy" 
set :runner, "deploy" 
set :use_sudo, true 

role :web, "my_ip"       
role :app, "my_ip"       
role :db, "my_ip", :primary => true 

set :normalize_asset_timestamps, false 
after "deploy", "deploy:cleanup" 

namespace :deploy do 
    desc "Restarting mod_rails with restart.txt" 
    task :restart, :roles => :app, :except => { :no_release => true } do 
     run "touch #{current_path}/tmp/restart.txt" 
    end 

    [:start, :stop].each do |t| 
     desc "#{t} task is a no-op with mod_rails" 
     task t, :roles => :domain do ; end 
    end 
end 

task :after_update_code do 
run "ln -nfs #{deploy_to}/shared/config/database.yml #{release_path}/config/database.yml" 
end 
+0

Tôi có chính xác như nhau khi triển khai ứng dụng đường ray 3.1 của tôi. Tôi nghĩ rằng đó là ẩn trong [sprockets rake task] (https://github.com/rails/rails/blob/master/actionpack/lib/sprockets/assets.rake) ở đâu đó, nhưng tôi không thấy nó. Nó có thể là nhiệm vụ 'tiền biên dịch: tài sản: nondigest' ghi lại cảnh báo cho stderr hay cái gì đó, và điều này được chọn bởi capistrano? – HectorMalot

+0

Để nói cho bạn biết sự thật, công cụ này là một chút trong phạm vi hiểu biết của tôi (vẫn gói đầu của tôi xung quanh biên dịch trước :) - nhưng tôi đã giới thiệu cho bạn bè và anh ấy nói điều này ... "Tôi không nghĩ rằng đó là lỗi tại tất cả Tôi nghĩ rằng đầu ra là sai lầm bằng cách nào đó, nghĩ rằng một dòng lỗi của nó khi sử dụng đầu ra bình thường miễn là triển khai kết thúc bạn nên được tốt, một lỗi thực sự ngừng thực hiện – fatfrog

Trả lời

1

sau, tôi nhận thấy rằng capistrano đã không thể xóa phiên bản cũ, tôi đã nhận ra lỗi:

*** [err :: ip_address] sudo: no tty present and no askpass program specified 

Tôi thấy liên kết này liên quan tới lỗi này: http://www.mail-archive.com/[email protected]/msg07323.html

tôi phải thêm dòng này vào tệp triển khai của tôi:

default_run_options[:pty] = true 

Điều này cũng giải quyết được lỗi lạ mà tôi đã nhận được ở trên.

Giải thích chính thức mà tôi không hiểu :)

Không có PTY mặc định. Trước 2.1, Capistrano sẽ yêu cầu một pseudo-tty cho mỗi lệnh mà nó thực thi. Điều này có tác dụng phụ gây ra các kịch bản hồ sơ cho người dùng không được tải. Vâng, không còn nữa! Tính đến 2,1, Capistrano không còn yêu cầu một pty trên mỗi lệnh, có nghĩa là .profile (hoặc .bashrc của bạn, hoặc bất cứ điều gì) sẽ được nạp đúng trên mỗi lệnh! Tuy nhiên, lưu ý rằng một số đã báo cáo trên một số hệ thống, khi một pty không được cấp phát, một số lệnh sẽ tự động chuyển sang chế độ không tương tác. Nếu bạn không thấy lời nhắc lệnh như họ đã từng sử dụng, như svn hoặc passwd, bạn có thể quay lại hành vi trước bằng cách thêm dòng sau vào capfile của bạn: default_run_options [: pty] = true

7

đầu tiên đừng quên thêm đá quý dưới

group :production do 
gem 'therubyracer' 
gem 'execjs' 
end 

sau đó trong tập tin nắp của bạn chỉ cần thêm dòng này trong after_update_code bạn

run "cd #{release_path}; rake assets:precompile RAILS_ENV=production " 

này làm việc tốt cho tôi;)

chúc mừng,

Gregory HORION

+4

hey dude, tôi sẽ khuyên bạn không để hiển thị của bạn ip trong tin nhắn của bạn, điều này có thể dẫn đến một số cuộc tấn công trên máy chủ của bạn;) cổ vũ – metakungfu

+0

Woops! :) gotta xem sao chép và dán! – fatfrog

2

Tôi gặp vấn đề tương tự . Tôi đã thêm điều này vào triển khai của mình.rb (để thêm tùy chọn '--trace'):

namespace :deploy do 
    namespace :assets do 
    task :precompile, :roles => :web, :except => { :no_release => true } do 
     run "cd #{current_path} && #{rake} RAILS_ENV=#{rails_env} RAILS_GROUPS=assets assets:precompile --trace" 
    end 
    end 
end 

Và lỗi có vẻ là chỉ thông báo:

*** [err :: my-server] ** Invoke assets:precompile (first_time) 
... 
1

Đây là những gì làm việc cho tôi:

1) Thêm RVM-capistrano để Gemfile bạn

2) trong confg/triển khai, thêm các dòng:

require 'rvm/capistrano' 
set :rvm_ruby_string, '1.9.2' # Set to your version number 

3) Bạn cũng có thể cần phải đặt: rvm_type và: rvm_bin_path. Xem this Ninjahideout blog để đi vào chi tiết hơn.

4) apt-get/yum install nodejs trên máy chủ của bạn

(Xem trả lời của tôi để related Stackoverflow question này.)

0

Thông điệp mà bạn nhìn thấy là sản phẩm của rake assets:precompile.

Khi bạn chạy rake assets:precompile, làm thế nào để tránh đầu ra mặc định

giải pháp là thêm -q behand lệnh của bạn,

phân tích là dưới đây, nếu bạn muốn xem:

# :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) } 
      ], 
Các vấn đề liên quan