Проблема с самоцветом Capistrano и Bitbucket - PullRequest
0 голосов
/ 10 апреля 2019

Когда я запускаю команду cap production deploy с моей локальной консоли, кажется, что почти все работает, потому что bundler:install генерирует ошибки:

$ cap production deploy
00:00 rvm1:hook
      ... OK (no error)
00:03 git:wrapper
      ... OK
00:06 git:check
      ... OK
00:08 deploy:check:directories
      ... OK
00:08 deploy:check:linked_dirs
      ... OK
00:10 git:clone
      ... OK
00:17 git:update
      ... OK
00:20 git:create_release
      ... OK
00:22 deploy:set_current_revision
      ... OK
00:23 deploy:symlink:linked_dirs
      ... OK
00:27 bundler:install
      01 /var/www/example.com/rvm1scripts/rvm-auto.sh . bundle install --path /var/www/example.com/shared/bundle --jobs 4 --without development test --deployment --quiet
      01 fatal: could not read Password for 'https://username@bitbucket.org': No such device or address
      01 fatal: could not read Password for 'https://username@bitbucket.org': No such device or address
      01 fatal: could not read Password for 'https://username@bitbucket.org': No such device or address
      01 fatal: could not read Password for 'https://username@bitbucket.org': No such device or address
      01 Git error: command `git clone
      01 'https://username@bitbucket.org/teamname/my_bitbucket_hosted_gem.git'
      01 "/var/www/example.com/shared/bundle/ruby/2.4.0/cache/bundler/git/my_bitbucket_hosted_gem-437e95a5134eb5a3d4cd4e857ff53ce2ad1d92f4"
      01 --bare --no-hardlinks --quiet` in directory
      01 /var/www/example.com/releases/20190409221020 has failed.


** DEPLOY FAILED
** Refer to log/capistrano.log for details. Here are the last 20 lines:


  INFO [fb97ffee] Finished in 0.488 seconds with exit status 0 (successful).
 DEBUG [d9926422] Running if test ! -d /var/www/example.com/releases/20190409221020; then echo "Directory does not exist '/var/www/example.com/releases/20190409221020'" 1>&2; false; fi as root@<***IP-ADDRESS***>
 DEBUG [d9926422] Command: if test ! -d /var/www/example.com/releases/20190409221020; then echo "Directory does not exist '/var/www/example.com/releases/20190409221020'" 1>&2; false; fi
 DEBUG [dfe89b2e] Finished in 0.486 seconds with exit status 0 (successful).
 DEBUG [2ddb11b1] Running /var/www/example.com/rvm1scripts/rvm-auto.sh . bundle check --path /var/www/example.com/shared/bundle as root@<***IP-ADDRESS***>
 DEBUG [2ddb11b1] Command: cd /var/www/example.com/releases/20190409221020 && /var/www/example.com/rvm1scripts/rvm-auto.sh . bundle check --path /var/www/example.com/shared/bundle
 DEBUG [8b5af7e4]   https://username@bitbucket.org/teamname/my_bitbucket_hosted_gem.git (at master@3d8b6b0) is not yet checked out. Run `bundle install` first.
 DEBUG [8b5af7e4] Finished in 1.484 seconds with exit status 11 (failed).
  INFO [42846bfe] Running /var/www/example.com/rvm1scripts/rvm-auto.sh . bundle install --path /var/www/example.com/shared/bundle --jobs 4 --without development test --deployment --quiet as root@<***IP-ADDRESS***>
 DEBUG [42846bfe] Command: cd /var/www/example.com/releases/20190409221020 && /var/www/example.com/rvm1scripts/rvm-auto.sh . bundle install --path /var/www/example.com/shared/bundle --jobs 4 --without development test --deployment --quiet
 DEBUG [03fa09da]   fatal: could not read Password for 'https://username@bitbucket.org': No such device or address
 DEBUG [03fa09da]   fatal: could not read Password for 'https://username@bitbucket.org': No such device or address
 DEBUG [03fa09da]   fatal: could not read Password for 'https://username@bitbucket.org': No such device or address
 DEBUG [03fa09da]   fatal: could not read Password for 'https://username@bitbucket.org': No such device or address
 DEBUG [03fa09da]   Git error: command `git clone 'https://username@bitbucket.org/teamname/my_bitbucket_hosted_gem.git' "/var/www/example.com/shared/bundle/ruby/2.4.0/cache/bundler/git/my_bitbucket_hosted_gem-437e95a5134eb5a3d4cd4e857ff53ce2ad1d92f4" --bare --no-hardlinks --quiet` in directory /var/www/example.com/releases/20190409221020 has failed.

Проблема, похоже, связана с размещенным в Bitbucket гемом и настройками пользователя (fatal: could not read Password for 'https://username@bitbucket.org': No such device or address). Как я могу решить это?

Примечание

Когда я запускаю команду bundle install локально (в режиме разработки), гем my_bitbucket_hosted_gem устанавливается без ошибок. Если в моем Gemfile (см. Ниже) я использую

gem 'my_bitbucket_hosted_gem', '0.1.3', :git => 'username@bitbucket.org/teamname/my_bitbucket_hosted_gem.git'    
# instead of (note 'https://'): gem 'my_bitbucket_hosted_gem', '0.1.3', :git => 'https://username@bitbucket.org/teamname/my_bitbucket_hosted_gem.git'

Когда я запускаю команду bundle install локально, я получаю ошибку:

Fetching username@bitbucket.org/teamname/my_bitbucket_hosted_gem.git
fatal: repository 'username@bitbucket.org/teamname/my_bitbucket_hosted_gem.git' does not exist

Кроме того, оба хранилища (unsername@bitbucket.org:teamname/example.git - см. Ниже) и гем (username@bitbucket.org/teamname/my_bitbucket_hosted_gem.git) находятся в Bitbucket.


По моему Gemfile у меня есть:

source 'https://rubygems.org'

...

gem 'my_bitbucket_hosted_gem', '0.1.3', :git => 'https://username@bitbucket.org/teamname/my_bitbucket_hosted_gem.git'

group :development do.
  gem "capistrano", "~> 3.11", require: false
  gem 'capistrano-bundler', '~> 1.5'
  gem "capistrano-rails", "~> 1.4", require: false
  gem 'capistrano-rvm'
end

По моему Capfile у меня есть:

# Load DSL and set up stages
require "capistrano/setup"

# Include default deployment tasks
require "capistrano/deploy"

# Load the SCM plugin appropriate to your project:
#
# require "capistrano/scm/hg"
# install_plugin Capistrano::SCM::Hg
# or
# require "capistrano/scm/svn"
# install_plugin Capistrano::SCM::Svn
# or
require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git

# Include tasks from other gems included in your Gemfile
require 'capistrano/bundler'
require 'capistrano/rails'
require "capistrano/rvm"
# require "capistrano/rbenv"
# require "capistrano/chruby"
# require "capistrano/passenger"

# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }

По моему /config/deploy.rb у меня есть:

# config valid for current version and patch releases of Capistrano
lock "~> 3.11.0"

# Application name
set :application, "example.com"

set :repo_url, "unsername@bitbucket.org:teamname/example.git"

# Default branch is :master
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp

# Default or :deploy_to is /var/www/my_app_name
set :deploy_to, -> { "/var/www/#{fetch(:application)}" } 

# Default value for :format is :airbrussh.
# set :format, :airbrussh

# You can configure the Airbrussh format using :format_options.
# These are the defaults.
# set :format_options, command_output: true, log_file: "log/capistrano.log", color: :auto, truncate: :auto

# Default value for :pty is false
# set :pty, true

# Default value for :linked_files is []
# append :linked_files, "config/database.yml"
append :linked_dirs, '.bundle'

# Default value for linked_dirs is []
# append :linked_dirs, "log", "tmp/pids", "tmp/cache", "tmp/sockets", "public/system"

# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }

# Default value for local_user is ENV['USER']
# set :local_user, -> { `git config user.name`.chomp }

# Default value for keep_releases is 5
# set :keep_releases, 5

# Uncomment the following to require manually verifying the host key before first deploy.
# set :ssh_options, verify_host_key: :secure

По моему config/deploy/production.rb у меня есть:

role :app, %w{root@<***IP-ADDRESS***>}
role :web, %w{root@<***IP-ADDRESS***>}
role :db,  %w{root@<***IP-ADDRESS***>}

Связанные темы, которые могут быть полезны:

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...