Capistrano编译资产错误 - 资产:预编译:非最小? [英] Capistrano compile assets error - assets:precompile:nondigest?

查看:144
本文介绍了Capistrano编译资产错误 - 资产:预编译:非最小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序似乎正在部署,但我收到这个错误:

  *执行cd / home / deploy / tomahawk / releases / 20120208222225&& bundle exec rake RAILS_ENV = production RAILS_GROUPS = assets assets:precompile
servers:[ip_address]
[ip_address]执行命令
*** [err :: ip_address] / opt / ruby​​ / bin / ruby​​ / opt / ruby​​ / bin / rake assets:precompile:nondigest RAILS_ENV = production RAILS_GROUPS = assets

我在这里尝试编译资产的方法: http://lassebunk.dk/2011/09/03/getting-your-assets-to-work-when-upgrading-to-rails-3 -1 /



此处: http://railsmonkey.net/2011/08/deploying-rails-3-1-applications-with-capistrano/



而这里:http://dev.af83.com/2011/09/30/capistrano-rails-3 -1-assets-can-be-tricky.html



这是我的deploy.rb:



pre $ 需要bundler / capistrano
加载'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

角色:web,my_ip
角色: app,my_ip
role:db,my_ip,:primary => true

set:normalize_asset_timestamps,false
deploy,deploy:cleanup

命名空间:deploy do
desc重新启动mod_rails .txt
task:restart,:roles => :app,:except => {:no_release =>执行
运行touch#{current_path} /tmp/restart.txt
end

[:start,:stop] .each do | t |
desc#{t}任务是与mod_rails无关的任务
任务t,:roles => :域做end
end
end

任务:after_update_code执行
运行ln -nfs#{deploy_to} /shared/config/database.yml#{release_path} / config /database.yml
end


解决方案

后来注意到capistrano不能删除旧版本,我收到一个错误:

  *** [err :: ip_address ] sudo:没有tty礼物,没有指定程序

我发现这个链接有关此错误:
http://www.mail-archive.com/capistrano@googlegroups .com / msg07323.html



我不得不将此行添加到我的部署文件中:

  default_run_options [:pty] = true 

这也解决了



官方说明,我不明白:)



否默认PTY。在2.1之前,Capistrano将为其执行的每个命令请求一个伪tty。这导致不能加载用户的配置文件脚本的副作用。好吧,没有更多!从2.1开始,Capistrano不再需要每个命令的pty,这意味着你的.profile(或.bashrc或者其他)将被正确加载到每个命令上!但是,请注意,有些报告在某些系统上,当pty未分配时,某些命令将自动进入非交互模式。如果您没有像以前那样看到像svn或passwd这样的命令提示符,可以通过向capfile添加以下行来返回上一行:default_run_options [:pty] = true


My App seems to be deploying correctly but I'm getting this error:

      * 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

I've tried solutions here for trying to compile assets: http://lassebunk.dk/2011/09/03/getting-your-assets-to-work-when-upgrading-to-rails-3-1/

And Here: http://railsmonkey.net/2011/08/deploying-rails-3-1-applications-with-capistrano/

And here: http://dev.af83.com/2011/09/30/capistrano-rails-3-1-assets-can-be-tricky.html

Here is my deploy.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

解决方案

I later noticed that capistrano wasn't able to delete old releases, I got an error:

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

I found this link regarding this error: http://www.mail-archive.com/capistrano@googlegroups.com/msg07323.html

I had to add this line to my deploy file:

default_run_options[:pty] = true

This also solved the weird error I was getting above.

The official explanation, which I don't understand :)

No default PTY. Prior to 2.1, Capistrano would request a pseudo-tty for each command that it executed. This had the side-effect of causing the profile scripts for the user to not be loaded. Well, no more! As of 2.1, Capistrano no longer requests a pty on each command, which means your .profile (or .bashrc, or whatever) will be properly loaded on each command! Note, however, that some have reported on some systems, when a pty is not allocated, some commands will go into non-interactive mode automatically. If you’re not seeing commands prompt like they used to, like svn or passwd, you can return to the previous behavior by adding the following line to your capfile: default_run_options[:pty] = true

这篇关于Capistrano编译资产错误 - 资产:预编译:非最小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆