capistrano 3“似乎不是一个混帐存储库”

当我尝试通过capistrano部署一个rails应用程序时遇到问题。 以下是我的当前configuration文件与编辑服务器名称:

configuration/ deploy.rb

lock '3.2.1' set :application, "my_app" set :repo_url, "my.server.example.com:/path/to/my_app.git" set :branch, 'master' set :use_sudo, false set :deploy_to, "/srv/#{fetch(:application)}" 

configuration/部署/ production.rb

 role :app, "my.server.example.com" role :web, "my.server.example.com" role :db, "my.server.example.com", :primary => true server 'my.server.example.com', user: 'root', roles: %w{web app}, ssh_options: { user: 'me', # overrides user setting above keys: %w(/home/me/.ssh/id_rsa), forward_agent: false, auth_methods: %w(publickey), verbose: :debug } 

基本上有三台电脑参与其中:

  1. 本地主机 ,我的工作站
  2. my.server.example.com托piperails应用程序
  3. my.git.example.com托pipe着git-repositories。

当我尝试部署时出现以下错误:

 [me@localhost my_app]$ cap production deploy INFO [d2263887] Running /usr/bin/env mkdir -p /tmp/my_app/ on my.server.example.com DEBUG [d2263887] Command: /usr/bin/env mkdir -p /tmp/my_app/ INFO [d2263887] Finished in 0.713 seconds with exit status 0 (successful). DEBUG Uploading /tmp/my_app/git-ssh.sh 0.0% INFO Uploading /tmp/my_app/git-ssh.sh 100.0% INFO [acbfa48d] Running /usr/bin/env chmod +x /tmp/my_app/git-ssh.sh on my.server.example.com DEBUG [acbfa48d] Command: /usr/bin/env chmod +x /tmp/my_app/git-ssh.sh INFO [acbfa48d] Finished in 0.005 seconds with exit status 0 (successful). DEBUG [b2d0392c] Running /usr/bin/env git ls-remote -h my.git.example.com:/path/to/repos/my_app.git on my.server.example.com DEBUG [b2d0392c] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/my_app/git-ssh.sh /usr/bin/env git ls-remote -h my.git.example.com:/path/to/repos/my_app.git ) DEBUG [b2d0392c] fatal: '/path/to/repos/my_app.git' does not appear to be a git repository DEBUG [b2d0392c] fatal: The remote end hung up unexpectedly DEBUG [b2d0392c] Finished in 1.025 seconds with exit status 128 (failed). 

进一步的调查使我相信这一行

 git ls-remote -h my.git.example.com:/path/to/repos/my_app.git 

产生错误,因为当我尝试在my.server.example.com上执行它时,它给了我完全相同的错误信息。 它工作,如果我修改它:

 git ls-remote -h me @my.git.example.com:/path/to/repos/my_app.git 

所以我有强烈的感觉,我的用户在某种程度上configuration错了,并会赞赏任何指向正确的方向。

这个问题的解决scheme其实很简单。 在config / deploy.rb中 ,我必须将forward_agent设置为true

 ssh_options: { user: 'me', # overrides user setting above keys: %w(/home/me/.ssh/id_rsa), forward_agent: true, auth_methods: %w(publickey), verbose: :debug }