当我从本地控制台运行命令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托管gem和用户设置(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
-参见下文)和gem(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***>}
可能有用的相关主题: