运行上限部署时的资产管道问题:Rails 3.1.3上的更新

时间:2011-12-11 20:56:33

标签: ruby-on-rails capistrano asset-pipeline

首次使用Capistrano部署应用程序,但在运行cap deploy:在Rails 3.1.3,Capistrano 2.9.0,RVM 1.8.6和Ubuntu服务器10.10上运行更新任务时出现问题。就我所见,不应该是权限问题。现在已经对我的头撞了一会儿,感谢任何指示。

drphil@mumindalen:~/Rails/testapp$ cap deploy:update
  * executing `deploy:update'
 ** transaction: start
  * executing `deploy:update_code'
    executing locally: "git ls-remote git@my_server:~/testapp/ HEAD"
git@23.23.23.23.'s password: 
command finished in 8892ms
  * executing "git clone -q git@my_server:~/testapp/         /home/deploy/testapp/releases/20111211183654 && cd /home/deploy/testapp/releases/20111211183654 && git checkout -q -b deploy f473e207b15d73d2fa9aa32ab1dbeec98471153d && (echo f473e207b15d73d2fa9aa32ab1dbeec98471153d > /home/deploy/testapp/releases/20111211183654/REVISION)"
servers: ["my_server"]
Password: 
[my_server] executing command
command finished in 1695ms
* executing `deploy:finalize_update'
triggering before callbacks for `deploy:finalize_update'
* executing `deploy:assets:symlink'
* executing "rm -rf /home/deploy/testapp/releases/20111211183654/public/assets &&\\\n        mkdir -p /home/deploy/testapp/releases/20111211183654/public &&\\\n        mkdir -p /home/deploy/testapp/shared/assets &&\\\n        ln -s /home/deploy/testapp/shared/assets /home/deploy/testapp/releases/20111211183654/public/assets"
servers: ["my_server"]
[my_server] executing command
command finished in 1117ms
* executing "chmod -R g+w /home/deploy/testapp/releases/20111211183654"
servers: ["my_server"]
[my_server] executing command
command finished in 614ms
* executing "rm -rf /home/deploy/testapp/releases/20111211183654/log /home/deploy/testapp/releases/20111211183654/public/system /home/deploy/testapp/releases/20111211183654/tmp/pids &&\\\n      mkdir -p /home/deploy/testapp/releases/20111211183654/public &&\\\n      mkdir -p /home/deploy/testapp/releases/20111211183654/tmp &&\\\n      ln -s /home/deploy/testapp/shared/log /home/deploy/testapp/releases/20111211183654/log &&\\\n      ln -s /home/deploy/testapp/shared/system /home/deploy/testapp/releases/20111211183654/public/system &&\\\n      ln -s /home/deploy/testapp/shared/pids /home/deploy/testapp/releases/20111211183654/tmp/pids"
servers: ["my_server"]
[my_server] executing command
command finished in 1022ms
* executing "find /home/deploy/testapp/releases/20111211183654/public/images /home/deploy/testapp/releases/20111211183654/public/stylesheets /home/deploy/testapp/releases/20111211183654/pu## Heading ##blic/javascripts -exec touch -t 201112111837.12 {} ';'; true"
servers: ["my_server"]
[my_server] executing command
*** [err :: my_server] find:
*** [err :: my_server] "/home/deploy/testapp/releases/20111211183654/public/images"
*** [err :: my_server] : Filen eller katalogen finns inte
*** [err :: my_server] 
*** [err :: my_server] find:
*** [err :: my_server] "/home/deploy/testapp/releases/20111211183654/public/stylesheets"
*** [err :: my_server] : Filen eller katalogen finns inte
*** [err :: my_server] 
*** [err :: my_server] find:
*** [err :: my_server] "/home/deploy/testapp/releases/20111211183654/public/javascripts"
*** [err :: my_server] : Filen eller katalogen finns inte
*** [err :: my_server] 
command finished in 1024ms
triggering after callbacks for `deploy:update_code'
  * executing `deploy:assets:precompile'
  * executing "cd /home/deploy/testapp/releases/20111211183654 && rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile"
servers: ["my_server"]
[my_server] executing command
*** [err :: my_server] sh:
*** [err :: my_server] rake: not found
*** [err :: my_server] 
command finished in 1440ms
*** [deploy:update_code] rolling back
  * executing "rm -rf /home/deploy/testapp/releases/20111211183654; true"
servers: ["my_server"]
[my_server] executing command
command finished in 727ms
failed: "sh -c 'cd /home/deploy/testapp/releases/20111211183654 && rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile'" on my_server

2 个答案:

答案 0 :(得分:4)

在开发盒和服务器上使用不同版本的RVM是一个问题,我没有set up deploy.rb properly与RVM一起工作。一直在挖掘几个小时,以为它是某种bug。哦,好吧。

让它在deploy.rb中使用它:

$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
require "rvm/capistrano"
set :rvm_ruby_string, 'ruby-1.9.2-p290'
set :rvm_type, :user

答案 1 :(得分:0)

找不到rake二进制文件。 如果您使用的是RVM,请确保您正在部署的用户位于rvm组中。

或者,很可能(或与上述相结合),您对非交互式shell禁用.bashrc / bashrc / profile环境。因此它不会加载所有配置(设置PATH等)。

请参阅http://lists.apple.com/archives/macos-x-server/2008/Jun/msg00251.html

Debian(/ etc / bashrc):

# System-wide .bashrc file for interactive bash(1) shells.

# To enable the settings / commands in this file for login shells as well,
# this file has to be sourced in /etc/profile.

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

......等等。 最后一行是问题所在。它退出处理非交互式shell的bashrc。 在你的系统上寻找类似的东西。

更新:

概述了在debian squeeze上处理的shell脚本: http://www.fam.tuwien.ac.at/~schamane/_/blog:110814_bash_shell_startup_files_in_debian_squeeze