【问题标题】:Capistrano 3 to ubuntu 14.04 git errorCapistrano 3 到 ubuntu 14.04 git 错误
【发布时间】:2014-09-28 08:20:58
【问题描述】:

由于 ubuntu 服务器上的 git 错误,我的 capistrino 检查失败。

得到这个日志

$ cap staging deploy:check --trace 
** Invoke staging (first_time)
** Execute staging
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke deploy:check (first_time)
** Execute deploy:check
** Invoke git:check (first_time)
** Invoke git:wrapper (first_time)
** Execute git:wrapper
INFO[bf639f43] Running /usr/bin/env mkdir -p /tmp/zarapp/ on 54.169.61.155
DEBUG[bf639f43] Command: /usr/bin/env mkdir -p /tmp/zarapp/
INFO[bf639f43] Finished in 1.368 seconds with exit status 0 (successful).
DEBUGUploading /tmp/zarapp/git-ssh.sh 0.0%
INFOUploading /tmp/zarapp/git-ssh.sh 100.0%
INFO[c06c1df0] Running /usr/bin/env chmod +x /tmp/zarapp/git-ssh.sh on 54.169.61.155
DEBUG[c06c1df0] Command: /usr/bin/env chmod +x /tmp/zarapp/git-ssh.sh
INFO[c06c1df0] Finished in 0.162 seconds with exit status 0 (successful).
** Execute git:check
DEBUG[d6b0ae0e] Running /usr/bin/env git ls-remote -h  on 54.169.61.155
DEBUG[d6b0ae0e] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/zarapp/git-ssh.sh /usr/bin/env git ls-remote -h  )
DEBUG[d6b0ae0e]     usage: git ls-remote [--heads] [--tags]  [-u <exec> | --upload-pack <exec>]
DEBUG[d6b0ae0e]     
DEBUG[d6b0ae0e]                          [-q|--quiet] [--exit-code] [--get-url] [<repository> [<refs>...]]
DEBUG[d6b0ae0e] Finished in 0.462 seconds with exit status 129 (failed).
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host 54.169.61.155: exit
/Library/Ruby/Gems/2.0.0/gems/capistrano-3.2.1/lib/capistrano/tasks/git.rake:28:in `exit'
/Library/Ruby/Gems/2.0.0/gems/capistrano-3.2.1/lib/capistrano/tasks/git.rake:28:in `block (4 levels) in <top (required)>'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/abstract.rb:85:in `with'
/Library/Ruby/Gems/2.0.0/gems/capistrano-3.2.1/lib/capistrano/tasks/git.rake:27:in `block (3 levels) in <top (required)>'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `run'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/runners/parallel.rb:13:in `block (2 levels) in execute'
SystemExit: exit
/Library/Ruby/Gems/2.0.0/gems/capistrano-3.2.1/lib/capistrano/tasks/git.rake:28:in `exit'
/Library/Ruby/Gems/2.0.0/gems/capistrano-3.2.1/lib/capistrano/tasks/git.rake:28:in `block (4 levels) in <top (required)>'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/abstract.rb:85:in `with'
/Library/Ruby/Gems/2.0.0/gems/capistrano-3.2.1/lib/capistrano/tasks/git.rake:27:in `block (3 levels) in <top (required)>'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `run'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/runners/parallel.rb:13:in `block (2 levels) in execute'
Tasks: TOP => git:check

我认为这是服务器上 git 的错误。我已经更新了它,但仍然没有成功。 我 ssh 到服务器并尝试直接运行git ls-remote -h 命令

DEBUG[d6b0ae0e] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/zarapp/git-ssh.sh /usr/bin/env git ls-remote -h  )
DEBUG[d6b0ae0e]     usage: git ls-remote [--heads] [--tags]  [-u <exec> | --upload-pack <exec>]
DEBUG[d6b0ae0e]     
DEBUG[d6b0ae0e]                          [-q|--quiet] [--exit-code] [--get-url] [<repository> [<refs>...]]

它也说同样的输出。 capistrino 3 是在运行错误的命令语法还是有其他问题?

【问题讨论】:

标签: git ubuntu capistrano3


【解决方案1】:

git ls-remote 需要一个 repo 才能运行。

意思是:

  • git ls-remote -h 总是会失败
  • 但这会起作用:

      git ls-remote -h /local/path/to/a/repo
      git ls-remote -h origin
    

正如 OP Hemc comments: "capistrano - git ls-remote -h doesn't have the git url" 确实指出 capistrano 版本不匹配(2.x 与 3.x)

见“Preparing Your Application

deploy.rb是可以指定每个环境通用配置的地方,通常在这里指定存储库URL和部署用户。

set :application, 'my app name'
    set :repo_url, 'git@example.com:me/my_repo.git'
    ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }

git ls-remote 将使用 repo_url 来执行。

【讨论】:

  • 感谢 Vonc,但我在 git repo 中运行此命令,我如何告诉 capistrino 远程运行此命令?
猜你喜欢
  • 2017-02-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-03-26
  • 2016-06-07
  • 2015-12-21
  • 2016-10-18
相关资源
最近更新 更多