Rails Capistrano Deploy - REVISION: No such file or directory

自古美人都是妖i 提交于 2019-12-14 04:06:54

问题


I'm using the Capistrano gem and this tutorial to deploy my application to my remote server. Everything works fine until the end of the cap deploy command. I'm receiving this error:

 ** [ps123456.dreamhostps.com :: out] sh: myapp.git/releases/20130916201449/REVISION: No such file or directory
    command finished in 2266ms
*** [deploy:update_code] rolling back
  * executing "rm -rf myapp.git/releases/20130916201449; true"
    servers: ["ps123456.dreamhostps.com"]
    [ps123456.dreamhostps.com] executing command
    command finished in 254ms
failed: "sh -c 'git clone --depth 1 ssh://username@ps123456.dreamhostps.com/~/myapp.git myapp.git/releases/20130916201449 && cd myapp.git/releases/20130916201449 && git checkout -b deploy 497af4d996358f8d1f42dc9658e276ee8d9fa64f && git submodule init && git submodule sync && export GIT_RECURSIVE=$([ ! \"`git --version`\" \\< \"git version 1.6.5\" ] && echo --recursive) && git submodule update --init $GIT_RECURSIVE && rm -Rf myapp.git/releases/20130916201449/.git && (echo 497af4d996358f8d1f42dc9658e276ee8d9fa64f > myapp.git/releases/20130916201449/REVISION)'" on ps123456.dreamhostps.com

Here is my deploy.rb:

require 'bundler/capistrano'
set :user, 'username'
set :domain, 'ps123456.dreamhostps.com'
set :applicationdir, "myapp.git"

default_run_options[:pty] = true
set :scm, 'git'
set :repository,  "ssh://username@ps123456.dreamhostps.com/~/myapp.git"
set :git_enable_submodules, 1 # if you have vendored rails
set :branch, 'master'
set :git_shallow_clone, 1
set :scm_verbose, true

# roles (servers)
role :web, domain
role :app, domain
role :db,  domain, :primary => true

# deploy config
set :deploy_to, applicationdir
set :deploy_via, :export

# additional settings
default_run_options[:pty] = true  # Forgo errors when deploying from windows

# Passenger
namespace :deploy do
  task :start do ; end
  task :stop do ; end
  task :restart, :roles => :app, :except => { :no_release => true } do
    run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
  end
end

What is going wrong?


回答1:


It's hard to say exactly, but it's clear that your releases/#{revision} dir is missing by the time you try to push the git revision into the file REVISION.

One likely issue that should probably get fixed is your :deploy_to dir is the same directory on the same machine as the git repo you are cloning from. Try this instead:

In your deploy.rb

set :deploy_to, "/home/#{user}/app/#{application}"

Then make sure to run this the first time:

cap deploy:setup

Then feel free to:

cap deploy



回答2:


After a lot of head scratching, oddly enough, it was cap deploy:setup that was my downfall. I am still unsure as to what was going on, but I have thoroughly tested and verified that deleting the deployment directory and redeploying the application without running cap deploy:setup will work.

For some reason, running cap deploy:setup, even after successful deploys, will cause permission errors and causes cap deploy to be unable to create and write to directories.



来源:https://stackoverflow.com/questions/18836635/rails-capistrano-deploy-revision-no-such-file-or-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!