Capistrano 不会创建版本

发布于 2024-12-18 02:27:56 字数 548 浏览 0 评论 0原文

当我运行 cap deploy 时,Capistrano 将尝试创建一个文件夹,例如 $HOME/sites/MY_APP/releases/TIMESTAMP。我可以看到该命令正在尝试运行,但它实际上不会创建该文件夹。

我可以直接从 Capistrano 输出中复制该命令并通过 SSH 运行该命令,它运行良好,没有任何问题。

该命令看起来是这样的:

cp -RPp /home/some_user/sites/my_cool_app/shared/cached-copy /home/some_user/sites/my_cool_app/releases/20111123164239 && (echo 59bf115868c2430cd0475ca1596998f1cfa3c084 > /home/some_user/sites/my_cool_app/releases/20111123164239/REVISION)

为什么该命令通过 Capistrano 会失败,但通过 SSH 终端会成功?

When I run cap deploy, Capistrano will attempt to create a folder such as $HOME/sites/MY_APP/releases/TIMESTAMP. I can see the command attempting to run, but it will not actually create the folder.

I can copy the command directly out of the Capistrano output and run the command over SSH and it works great with no problems.

The command looks something so:

cp -RPp /home/some_user/sites/my_cool_app/shared/cached-copy /home/some_user/sites/my_cool_app/releases/20111123164239 && (echo 59bf115868c2430cd0475ca1596998f1cfa3c084 > /home/some_user/sites/my_cool_app/releases/20111123164239/REVISION)

Why would the command fail through Capistrano, but succeed through an SSH terminal?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

二智少女猫性小仙女 2024-12-25 02:27:56

我仍然不确定问题从哪里开始,但删除了这一行:

set :deploy_via, :remote_cache

为我解决了问题。它看起来像是一个错误,未创建发布目录,因此删除该行会跳过该步骤。如果您想保留remote_cache,更好的方法可能是添加另一个设置步骤,如下所示:

after "deploy:setup", "deploy:create_release_dir"
namespace :deploy do
  task :create_release_dir, :except => {:no_release => true} do
    run "mkdir -p #{fetch :releases_path}"
  end
end

I'm still not sure where the problem spans from but removing the line:

set :deploy_via, :remote_cache

Solved things for me. It looks like a bug where the releases directory isn't being created and so removing that line skips that step. A better approach if you want to keep the remote_cache is probably to add another step to setup like so:

after "deploy:setup", "deploy:create_release_dir"
namespace :deploy do
  task :create_release_dir, :except => {:no_release => true} do
    run "mkdir -p #{fetch :releases_path}"
  end
end
迷离° 2024-12-25 02:27:56

忽略绿色线以下的部分,但我会保留它们,仅供其他人参考。

当我使用 Capistrano 3.9.x 版本时,发生了上述问题。当我降级到版本 3.4.0 时,一切正常。


答案的第二部分:

有一次这种情况发生在我身上,是因为 github 密钥没有在 ~/.ssh/ 中设置。

您应该在服务器上生成 ssh 密钥。在 ~/.ssh 中生成 .pub 文件后,您应该转到 github.com(或任何其他服务)并在网络上添加新生成的 ssh 密钥-site(应该在设置页面或类似页面下找到)。
另外,在服务器上在 ~/.ssh/config 文件中添加一条与 capistrano 部署脚本中的标识相匹配的正确记录:

set :repo_url, proc { "[email protected]:your_git_name/#{fetch(:application)}.git" }

因此 config 文件应如下所示:

Host github.com
  HostName github.com
    User git
      IdentityFile ~/.ssh/id_rsa_my_new_key_on_the_server

Ignore part below the green lineline, but I will keep them, just for reference for others.

The mentioned issue was happening for me when I was using Capistrano 3.9.x version. When I downgraded to version 3.4.0 it was all working.


Second part of the answer:

Once this happened to me was when the github keys were not set up in ~/.ssh/.

You should generate a ssh key on the server. Once the .pub file is generated in ~/.ssh then you should go to github.com (or any other service) and add you newly generated ssh key on the web-site (it should be found under settings page or similar).
Also, on the server add a proper record in ~/.ssh/config file which matches the identification in the capistrano deploy script:

set :repo_url, proc { "[email protected]:your_git_name/#{fetch(:application)}.git" }

So the config file should look like this:

Host github.com
  HostName github.com
    User git
      IdentityFile ~/.ssh/id_rsa_my_new_key_on_the_server
半城柳色半声笛 2024-12-25 02:27:56

就我而言,只需将此行添加到deploy.rb 文件中

set :scm, :git

In my case it was a matter of adding this line into deploy.rb file

set :scm, :git
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文