Capistrano 不会创建版本
当我运行 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我仍然不确定问题从哪里开始,但删除了这一行:
为我解决了问题。它看起来像是一个错误,未创建发布目录,因此删除该行会跳过该步骤。如果您想保留remote_cache,更好的方法可能是添加另一个设置步骤,如下所示:
I'm still not sure where the problem spans from but removing the line:
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:
忽略绿色线以下的部分,但我会保留它们,仅供其他人参考。
当我使用 Capistrano
3.9.x
版本时,发生了上述问题。当我降级到版本3.4.0
时,一切正常。答案的第二部分:
有一次这种情况发生在我身上,是因为 github 密钥没有在
~/.ssh/
中设置。您应该在服务器上生成 ssh 密钥。在
~/.ssh
中生成.pub
文件后,您应该转到 github.com(或任何其他服务)并在网络上添加新生成的 ssh 密钥-site(应该在设置页面或类似页面下找到)。另外,在服务器上在
~/.ssh/config
文件中添加一条与 capistrano 部署脚本中的标识相匹配的正确记录:因此
config
文件应如下所示: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 version3.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:So the
config
file should look like this:就我而言,只需将此行添加到deploy.rb 文件中
In my case it was a matter of adding this line into deploy.rb file