gpt4 book ai didi

ruby-on-rails - rails 4 + Capistrano 3 : fatal: Could not read from remote repository while deploying

转载 作者:行者123 更新时间:2023-12-03 22:48:28 26 4
gpt4 key购买 nike

使用 Capistrano 3 部署 Rails 4 应用程序时出现以下错误

INFO [87512eb8] Running /usr/bin/env chmod +x /tmp/magnificent/git-ssh.sh as deploy@104.236.6.180
DEBUG [87512eb8] Command: /usr/bin/env chmod +x /tmp/magnificent/git-ssh.sh
INFO [87512eb8] Finished in 0.444 seconds with exit status 0 (successful).
INFO [1ec94dd1] Running /usr/bin/env git ls-remote --heads git@github.com:BoTreeConsultingTeam/magnificent.git as deploy@104.236.6.180
DEBUG [1ec94dd1] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/magnificent/git-ssh.sh /usr/bin/env git ls-remote --heads git@github.com:BoTreeConsultingTeam/magnificent.git )
DEBUG [1ec94dd1] ERROR: Repository not found.
DEBUG [1ec94dd1] fatal: Could not read from remote repository.
DEBUG [1ec94dd1]
DEBUG [1ec94dd1] Please make sure you have the correct access rights
DEBUG [1ec94dd1] and the repository exists.

这是 capistrano 配置。

配置/部署.rb
# config valid only for current version of Capistrano
lock '3.4.0'

set :application, 'magnificent'
set :repo_url, 'git@github.com:BoTreeConsultingTeam/magnificent.git'
set :deploy_to, '/home/deploy/magnificent'

set :linked_files, %w{config/database.yml config/secrets.yml}
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
set :branch, 'develop' #set/ :branch,`git rev-parse --abbrev-ref HEAD`.chomp
set :ssh_options, { forward_agent: true }

namespace :deploy do

desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
execute :touch, release_path.join('tmp/restart.txt')
end
end

after :publishing, 'deploy:restart'
after :finishing, 'deploy:cleanup'
end

namespace :deploy do

after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
# Here we can do anything such as:
# within release_path do
# execute :rake, 'cache:clear'
# end
end
end

end

生产.rb
set :stage, :production
server 'xx.xx.xx.xx', user: 'deploy', roles: %w{web app}

Capfile
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rvm'
require 'capistrano/bundler'
require 'capistrano/rails'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
set :rvm_type, :user
set :rvm_ruby_version, '2.2.2'

我还将远程服务器的/home/deploy/.ssh/id_rsa.pub 复制到 github 部署 key 。

更新
我确认我可以访问远程 repo 以及 GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/magnificent/git-ssh.sh /usr/bin/env git ls-remote --heads git@github.com:BoTreeConsultingTeam/magnificent.git命令适用于远程服务器。

最佳答案

当前解决方案

最近我使用了不同的解决方案。之前 cap production deploy我运行以下命令。

  • eval "$(ssh-agent -s)"
  • ssh-add ~/.ssh/id_rsa

  • 以前的解决方案

    我可以通过替换来解决这个问题
    set :repo_url, 'git@github.com:BoTreeConsultingTeam/magnificent.git'


    set :repo_url, 'https://my_github_username:my_github_password@github.com/BoTreeConsultingTeam/magnificent'

    备注 如果您的密码包含特殊字符,那么它应该是 url 编码的。您可以使用 URI::encode 快速编码在 irb。

    对于使用 Capistrano 2 的其他部署,我从不需要提供 github 凭据。

    谁能告诉我为什么我必须在 repo_url 中指定 git 用户名/密码?

    upcase forum post中还有一个解决方案这也有效。

    关于ruby-on-rails - rails 4 + Capistrano 3 : fatal: Could not read from remote repository while deploying,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31855914/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com