1

When I run the command cap production deploy from my local console almost all seems to work because bundler:install generates errors:

$ 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.

The problem seems related to the Bitbucket hosted gem and the user settings (fatal: could not read Password for 'https://username@bitbucket.org': No such device or address). How can I solve it?

Note:

When I run the command bundle install locally (in development mode), the gem my_bitbucket_hosted_gem is installed without errors. If in my Gemfile (see below) I use

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'

When I run the command bundle install locally I get the error:

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

Also, both the repository (unsername@bitbucket.org:teamname/example.git - see below) and the gem (username@bitbucket.org/teamname/my_bitbucket_hosted_gem.git) are on Bitbucket.


In my Gemfile I have:

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

In my Capfile I have:

# 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 }

In my /config/deploy.rb I have:

# 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

In my config/deploy/production.rb I have:

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

Related topics that could be useful:

Backo
  • 18,291
  • 27
  • 103
  • 170
  • if you already have downloaded the gem on your local machine it wont be going out and trying to grab it. it just gets it locally. when i have had these types of errors, it has usually turned out to be a typo somewhere. – Timmy Von Heiss Apr 10 '19 at 04:50
  • have you tried `:git => 'https://my_username:my_password@github.com/my_github_account/my_repo.git'` ? – Timmy Von Heiss Apr 10 '19 at 04:54
  • 1
    @TimmyVonHeiss my gem repo is hosted on Bitbucket `:git => 'https://username@bitbucket.org/teamname/my_bitbucket_hosted_gem.git'`. Should the plain password be avoided in Gemfile? – Backo Apr 10 '19 at 08:18
  • I am also investigating whether the problem is related to forwarding ssh. – Backo Apr 10 '19 at 08:40
  • i don't think i have ever seen it written that way. if it is a private repo you would need the username *and* password and you could use ENV for the password. otherwise it is just a url such as `git: 'https://github.com/sealink/loofah-activerecord.git'` – Timmy Von Heiss Apr 10 '19 at 16:33
  • It should work in theory with gem 'mygem', bitbucket: 'repoteam/reponame' - but I have not found a way to do this that does not put one's password in source-control. The bundle config method doesn't work with bitbucket either - get prompted for password every time with every pattern I have tried. – JosephK Jan 09 '20 at 06:54

0 Answers0