我已经在JRuby(1.7.10)中开发了一个新的Rails(4.1.4)应用程序,并且一段时间以来,我一直在Capistrano v3上将其部署在远程vps上。现在,部署者脚本突然无法访问Bitbucket上的存储库。错误看起来像:
DEBUG[a45f3340] Running /usr/bin/env git ls-remote -h git@bitbucket.org:ACCNAME/APPNAME.git on APPNAME.cloudapp.net
DEBUG[a45f3340] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/USER/git-ssh.sh /usr/bin/env git ls-remote -h git@bitbucket.org:ACCNAME/APPNAME.git )
DEBUG[a45f3340] conq: repository access denied.
DEBUG[a45f3340]
DEBUG[a45f3340] fatal: Could not read from remote repository.
DEBUG[a45f3340]
DEBUG[a45f3340]
DEBUG[a45f3340] Please make sure you have the correct access rights
DEBUG[a45f3340]
DEBUG[a45f3340] and the repository exists.
DEBUG[a45f3340]
DEBUG[a45f3340] Finished in 4.289 seconds with exit status 128 (failed).
尽管当我登录到远程服务器并运行相同的命令时,它仍成功执行并连接了Bitbucket存储库。
这是Gemfile的样子:
source 'https://rubygems.org'
ruby '1.9.3', :engine => 'jruby', :engine_version => '1.7.10'
gem 'rails', '4.1.4'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'therubyrhino'
gem 'jquery-rails'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'activerecord-jdbcmysql-adapter'
gem 'devise'
gem 'devise_invitable', :github => 'scambra/devise_invitable'
gem "paperclip"
gem 'acts_as_list'
gem 'pry-rails', group: :development
gem 'rubyzip'
gem 'to_bool', '~> 1.0.1'
gem "jquery-fileupload-rails"
# Use Capistrano for deployment
gem 'capistrano', group: :development
gem 'capistrano-rvm', group: :development
gem 'capistrano-bundler', group: :development
gem 'capistrano-rails', group: :development
gem 'trinidad', require: false
gem 'rvm1-capistrano3', require: false
上限文件:
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rvm'
require 'capistrano/bundler'
require 'capistrano/rails'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
require 'rvm1/capistrano3'
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
deploy.rb:
# config valid only for Capistrano 3.1
lock '3.2.1'
set :bundle_flags, '--deployment' # tried removing switch deployment if installing as system gem helps
set :deploy_user, "deployer"
set :application, 'APPNAME'
set :repo_url, 'git@bitbucket.org:user/repo.git'
server "example.net", user: 'deployer', roles: [:web, :app, :db]
set :rvm_type, :user
set :rvm1_ruby_version, 'jruby-1.7.10'
set :scm, :git
set :pty, true
set :deploy_to, "/home/#{fetch(:deploy_user)}/apps/#{fetch(:application)}"
set :linked_files, %w{config/database.yml}
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
set :keep_releases, 5
after "deploy", "deploy:cleanup"
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, :restart
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
namespace :deploy do
desc "Install everything onto the server"
task :install do
on roles(:all), in: :sequence, wait: 1 do
execute 'mkdir', '-p', fetch(:deploy_to)
execute :sudo, 'apt-get', '-y', "update"
execute :sudo, 'apt-get', '-y', "install", "build-essential zlib1g-dev libssl-dev libreadline-gplv2-dev python-software-properties curl git-core openjdk-7-jdk jsvc"
end
end
end
这里要注意的一件事是,我不断收到来自rvm的警告
Warning! PATH is not properly set up, '/Users/username/.rvm/gems/ruby-2.1.0/bin' is not at first place,
usually this is caused by shell initialization files - check them for 'PATH=...' entries,
it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
to fix temporarily in this shell session run: 'rvm use ruby-2.1.0'.
因此,我运行了
rvm get stable --auto-dotfiles
,我认为问题在此之后开始。但这就是我的假设。我可能错了。我试图通过cap production rvm1:install:rvm
重新安装服务器的rvm,但这没有帮助。有人可以指出出什么问题了吗?
最佳答案
在我的情况下,这是一个ssh-agent问题,我通过在capistrano ssh-user eval $(ssh-agent) > /dev/null
中添加.bashrc
来解决了该问题。
本文对我有帮助:https://peteoliveira.com/deploying-with-capistrano-3-failing-permission-denied-publickey/
关于ruby-on-rails - rvm和Capistrano:无法在Bitbucket “conq: repository access denied.”上克隆git存储库,但可以从服务器内部手动访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25937506/