【问题标题】:Capistrano tmp:dir error:cannot run git-ssh.sh: No such file or directoryCapistrano tmp:dir error:cannot run git-ssh.sh: No such file or directory
【发布时间】:2024-01-01 04:10:01
【问题描述】:

在我的服务器上,我不允许创建执行任何内容的 tmp 文件夹。 因此,使用 capistrano 3,我可以选择为一种自定义 tmp 文件夹设置路径。 有没有我必须考虑的语法,导致我的设置在 cap staging deploy 中执行错误:

INFO[f99c486e] Running /usr/bin/env mkdir -p custom_tmp/myproject/ on xxxx.de
DEBUG[f99c486e] Command: /usr/bin/env mkdir -p custom_tmp/myproject/
INFO[f99c486e] Finished in 1.140 seconds with exit status 0 (successful).
DEBUGUploading custom_tmp/myproject/git-ssh.sh 0.0%
INFOUploading custom_tmp/myproject/git-ssh.sh 100.0%
INFO[91b7d9b8] Running /usr/bin/env chmod +x custom_tmp/myproject/git-ssh.sh on xxxx.de
DEBUG[91b7d9b8] Command: /usr/bin/env chmod +x custom_tmp/myproject/git-ssh.sh
INFO[91b7d9b8] Finished in 0.080 seconds with exit status 0 (successful).
DEBUG[f4db290c] Running /usr/bin/env git ls-remote -h git@bitbucket.org:hallo/www.myproject.de.git on xxxx.de
DEBUG[f4db290c] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=custom_tmp/myproject/git-ssh.sh /usr/bin/env git ls-remote -h git@bitbucket.org:hallo/www.myproject.de.git )
DEBUG[f4db290c]     66791b22a61cd1af57d117a817129e491e83d88c    refs/heads/master
DEBUG[f4db290c] Finished in 3.235 seconds with exit status 0 (successful).
INFO[74118c8e] Running /usr/bin/env mkdir -pv development/myproject/shared development/myproject/releases on xxxx.de
DEBUG[74118c8e] Command: /usr/bin/env mkdir -pv development/myproject/shared development/myproject/releases
INFO[74118c8e] Finished in 0.079 seconds with exit status 0 (successful).
INFO[10e40636] Running /usr/bin/env mkdir -pv development/myproject/shared/media on xxxx.de
DEBUG[10e40636] Command: /usr/bin/env mkdir -pv development/myproject/shared/media
INFO[10e40636] Finished in 0.086 seconds with exit status 0 (successful).
DEBUG[38889a64] Running /usr/bin/env [ -f development/myproject/current/REVISION ] on xxxx.de
DEBUG[38889a64] Command: [ -f development/myproject/current/REVISION ]
DEBUG[38889a64] Finished in 0.079 seconds with exit status 1 (failed).
DEBUG[5dfc387f] Running /usr/bin/env [ -f development/myproject/repo/HEAD ] on xxxx.de
DEBUG[5dfc387f] Command: [ -f development/myproject/repo/HEAD ]
DEBUG[5dfc387f] Finished in 0.095 seconds with exit status 1 (failed).
DEBUG[44d0214c] Running /usr/bin/env if test ! -d development/myproject/; then echo "Directory does not exist 'development/myproject/'" 1>&2; false; fi on xxxx.de
DEBUG[44d0214c] Command: if test ! -d development/myproject/; then echo "Directory does not exist 'development/myproject/'" 1>&2; false; fi
DEBUG[44d0214c] Finished in 0.079 seconds with exit status 0 (successful).
INFO[dac1f8fd] Running /usr/bin/env git clone --mirror git@bitbucket.org:hallo/www.myproject.de.git development/myproject/repo on xxxx.de
DEBUG[dac1f8fd] Command: cd development/myproject/ && ( GIT_ASKPASS=/bin/echo GIT_SSH=custom_tmp/myproject/git-ssh.sh /usr/bin/env git clone --mirror git@bitbucket.org:hallo/www.myproject.de.git development/myproject/repo )
DEBUG[dac1f8fd]     Cloning into bare repository development/myproject/repo...
DEBUG[dac1f8fd]     error: cannot run custom_tmp/myproject/git-ssh.sh: No such file or directory
DEBUG[dac1f8fd]     fatal: unable to fork
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host xxxx.de: git exit status: 128
git stdout: Nothing written
git stderr: Nothing written

在我的服务器上,文件夹“custom_tmp/myproject/”与 git-ssh.sh 一起仍然存在。所以我想知道这个错误。 这是我的 deploy.rb

#config valid only for Capistrano 3.1
lock '3.2.1'

set :application, 'myproject'
set :repo_url, 'git@bitbucket.org:hallo/www.myproject.de.git'

# Default deploy_to directory is /var/www/my_app
set :deploy_to, 'development/myproject/'

#Default value for :scm is :git
#set :scm, :git

#Default value for :format is :pretty
#set :format, :pretty

# Default value for :log_level is :debug
set :log_level, :debug

#Default value for :pty is false
set :pty, true

# Default value for :linked_files is []
# set :linked_files, %w{config/database.yml}

# Default value for linked_dirs is []
set :linked_dirs, %w{media}

#tmp dir 
set :tmp_dir,"custom_tmp"

namespace :deploy do

  desc 'Restart application'
  task :restart do
    on roles(:app) do
      # Your restart mechanism here, for example:
      # execute :touch, release_path.join('tmp/restart.txt')
    end
  end

end

【问题讨论】:

    标签: capistrano dir tmp


    【解决方案1】:

    好的,我离我更近了一步。 我的 tmp 目录的路径不正确。 我在我的服务器上做了一个 pwd 并将显示的路径放在我的“custom_tmp”前面,例如:

    set :tmp_dir,"/cutomer/homeages/13/233232/custom_tmp"

    但是根据 repo 文件夹的新错误导致 cap staging deploy 中断:

    致命:目标路径 'development/www.myproject.com/repo' 已存在且不是空目录。

    【讨论】:

      【解决方案2】:

      好的, 我得到了它。 必须对以下内容做同样的事情: 设置:deploy_to

      【讨论】: