Home>

I'm currently trying to create an app to enable automatic deployment with Capistrano.

While referring to the article below, we are proceeding with the introduction, all the work items have been completed,
bundle exec cap production deployWhen I ran the command, an error occurred.

How to install automatic deployment tool (Capistrano)

Error status Terminal (local)
nakayakouyuu @ nakayakouyuunoMacBook-Pro smot% bundle exec cap production deploy
[Deprecation Notice] Future versions of Capistrano will not load the Git SCM
plugin by default. To silence this deprecation warning, add the following to
your Capfile after `require" capistrano/deploy "`:
    require "capistrano/scm/git"
    install_plugin Capistrano :: SCM :: Git
00:00 git: wrapper
      01 mkdir -p/tmp
    ✔ 01 [email protected] 0.239s
      Uploading /tmp/git-ssh-smot-production-nakayakouyuu.sh 100.0%
      02 chmod 700 /tmp/git-ssh-smot-production-nakayakouyuu.sh
    ✔ 02 [email protected] 0.291s
00:00 git: check
      01 git ls-remote [email protected]: nakaya-kousuke/smot.git HEAD
      01 5e943870f1583d9775b045f3c40d418324d8ad8a HEAD
    ✔ 01 [email protected] 2.098s
00:02 deploy: check: directories
      01 mkdir -p/var/www/smot/shared/var/www/smot/releases
    ✔ 01 [email protected] 0.132s
00:03 deploy: check: linked_dirs
      01 mkdir -p/var/www/smot/shared/log/var/www/smot/shared/tmp/pids/var/www/smot/shared/tmp/cache/var/www/smot/shared/tmp/sockets/var/www/smot/sha…
    ✔ 01 [email protected] 0.224s
00:03 git: clone
      The repository mirror is at/var/www/smot/repo
00:03 git: update
      01 git remote set-url origin [email protected]: nakaya-kousuke/smot.git
    ✔ 01 [email protected] 0.237s
      02 git remote update --prune
      02 Fetching origin
    ✔ 02 [email protected] 2.093s
00:06 git: create_release
      01 mkdir -p/var/www/smot/releases/20201103133334
    ✔ 01 [email protected] 0.226s
      02 git archive master |/usr/bin/env tar -x -f --- C/var/www/smot/releases/20201103133334
      02 fatal: not a valid object name: master02 tar:
      02 This doesn't seem to be a tar archive
      02 02
      02 tar:
      02 Exit with failure status due to previous error
      02 02
#<Thread: [email protected]/Users/nakaya-kousuke/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/sshkit-1.21.0/lib/sshkit/runners/parallel.rb: 10 run>terminated with exception (report_on_exception is true):
Traceback (most recent call last):
        1: from /Users/nakaya-kousuke/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/sshkit-1.21.0/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute'
/Users/nakaya-kousuke/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/sshkit-1.21.0/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute': Exception while executing as [email protected]: git exit status: 2 (SSHKit :: Runner :: ExecuteError)
git stdout: Nothing written
git stderr: fatal: not a valid object name: master
tar: This doesn't seem to be a tar archive
tar: exit with failure status due to previous error
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit :: Runner :: ExecuteError: Exception while executing as [email protected]: git exit status: 2
git stdout: Nothing written
git stderr: fatal: not a valid object name: master
tar: This doesn't seem to be a tar archive
tar: exit with failure status due to previous error

Caused by:
SSHKit :: Command :: Failed: git exit status: 2
git stdout: Nothing written
git stderr: fatal: not a valid object name: master
tar: This doesn't seem to be a tar archive
tar: exit with failure status due to previous error
Tasks: TOP =>git: create_release
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as [email protected]: git exit status: 2
git stdout: Nothing written
git stderr: fatal: not a valid object name: master
tar: This doesn't seem to be a tar archive
tar: exit with failure status due to previous error
What I checked

When I googled "tar: This doesn't seem to be a tar archive", I found the following article:

[Terraform + capistrano + itamae] A memorandum when deploying a Rails application to aws ②

It says "The branch name to deploy specified in =>Capfile was different."
Since the branch name is not written in Capfile, is it the branch name of deploy.rb? I thought, I checked it, but it was definitely described.

Capfile
require "capistrano/setup"
require "capistrano/deploy"
require'capistrano/rbenv'
require'capistrano/bundler'
require'capistrano/rails/assets'
require'capistrano/rails/migrations'
require'capistrano3/unicorn'
Dir.glob ("lib/capistrano/tasks/*. rake"). each {| r | import r}
deploy.rb
# config valid only for current version of Capistrano
Described the version of #capistrano. Continue to use the fixed version and prevent troubles due to version change
lock '3.14.1'
Used to display # Capistrano logs
set: application,'smot'
# Specify from which repository I want to pull your app
set: repo_url,'[email protected]: nakaya-kousuke/smot.git'
#Specify a directory to be referenced in common even if the version changes
set: linked_dirs, fetch (: linked_dirs, []). push ('log','tmp/pids','tmp/cache','tmp/sockets','vendor/bundle','public/system',' public/uploads')
set: rbenv_type,: user
set: rbenv_ruby, '2.5.1' # If i follow the curriculum, it's 2.5.1 or 2.3.1.
#Which public key to use for deployment
set: ssh_options, auth_methods: ['publickey'],


                  keys: ['~/.ssh/smot.pem']
#Location of the file containing the process number
set: unicorn_pid,->{"# {shared_path} /tmp/pids/unicorn.pid"}
# Unicorn configuration file location
set: unicorn_config_path,->{"# {current_path} /config/unicorn.rb"}
set: keep_releases, 5
# Description for restarting Unicorn after the deployment process is finished
after'deploy: publishing','deploy: restart'
namespace: deploy do
  task: restart do
    invoke'unicorn: restart'
  end
end

I would like to know what kind of error this is and how to resolve the error.

  • Answer # 1

    Has the master branch on github been renamed to the main branch?
    If so
    Try adding the following to deploy.rb.

    set: branch,'main'

    I'm fine with this.