Capistrano error tar: This does not look like a tar archive
Asked Answered
U

7

116
 INFO [050fe961] Running mkdir -p /home/rails/rails-
capistrano/releases/20140114234157 on staging-rails
DEBUG [050fe961] Command: cd /home/rails/rails-capistrano/repo && ( PATH=/opt/ruby/bin:$PATH GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/rails/git-ssh.sh mkdir -p /home/rails/rails-capistrano/releases/20140114234157 )
 INFO [050fe961] Finished in 0.142 seconds with exit status 0 (successful).
 INFO [2dea2fe5] Running git archive feature/Capistrano | tar -x -C /home/rails/rails-capistrano/releases/20140114234157 on staging-rails
DEBUG [2dea2fe5] Command: cd /home/rails/rails-capistrano/repo && ( PATH=/opt/ruby/bin:$PATH GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/rails/git-ssh.sh git archive feature/Capistrano | tar -x -C /home/rails/rails-capistrano/releases/20140114234157 )
DEBUG [2dea2fe5]    fatal: Not a valid object name
DEBUG [2dea2fe5]    tar: This does not look like a tar archive
DEBUG [2dea2fe5]    tar: 
DEBUG [2dea2fe5]    Exiting with failure status due to previous errors      

I am confused about two things:

  1. Why is Capistrano running git archive here:
    git archive feature/Capistrano | tar -x -C /home/rails/rails-capistrano/releases/20140114234157

  2. Why is tar failing?

Unmusical answered 14/1, 2014 at 23:53 Comment(0)
S
368

I had the same issue, until I realized I was pulling the nonexistent branch from git.

Schoolmarm answered 29/5, 2014 at 15:9 Comment(17)
Such a forehead smacker.Bergstein
Second time i encounter your answer, second time this happened, i feel dumb!Coth
Dumb, dumb, dumb. Though, I do have an excuse (here we go!) I was copy/pasting config from another project. (I know, shameful.)Acrilan
I'm glad that this question has so many upvotes. At least I don't fail lonely.Homogamy
This may be a reason for the problem but does not really answer the questions presented. Eric didn't seem to resolve his issue this way. I'll post an alt. answer.Graber
if I am here, I am also the dump, thank you for solution btwSnowdrop
God Bless you, I could spend a whole dayFlamen
Seriously, this is probably the 42nd time I'm doing the same google search and reading this answer xDLuba
there should be check of the branch nameTimpani
I spent 5 minutes thinking "This is not my problem"... Yes it was.Serg
I have joined the cclub today!Kerr
Even now, four years later, this answer is still relevant. Many thanks!Hepner
You just saved my 5+ hours which i was estimating to put in resolving this.. God bless you the saviourEvslin
faced the same issue. I intended to deploy main branch and it was searching for master branch. Then I did bundle exec cap production deploy BRANCH=main see this for referenceFlourishing
It's so fun :)), I had a problem the same. Many thanksBlest
Now that more people are using a main branch instead of master, I suspect more people will face this issue :)Ludvig
You can set your branch on deploy.rb with: set :branch, "main" PS Go upvote yosefbennywidyo answerLength
S
19

Deleting app_name/repo also fixed this issue for me.

Ser answered 27/5, 2014 at 16:55 Comment(1)
This has worked for me some times whenever there are repo issues with cap deploy but not always.Graber
R
19

This happens when the repo in the server to deploy is messed up. We're talking about the bare git repo that Capistrano by default would put in /var/www/$application/repo (for other people's reference).

In your case it does not have a local feature/Capistrano branch so when running git archive feature/Capistrano nothing is output to that | pipe. To confirm, ssh into the server, cd into /home/rails/rails-capistrano/repo, and run git branch.

  1. It's running git archive as a way to export the selected branch's tree. git archive "writes it out to the standard output" so Capistrano redirects that to tar in order to uncompress the archive immediately into your new release directory. (Why Capistrano chose this instead of git checkout defeats me.)

  2. tar fails because it's receiving nothing d:

I can think of two possible solutions/ways to troubleshoot:

  • ssh into the server and manually delete the repo folder (e.g. in your case /home/rails/rails-capistrano/repo) as mentioned by @lugolabs
  • make sure the server's repo is using the remote you're expecting (ssh in, cd into repo/, and run git remote -v) -- you may just need to update your :repo_url in deploy.rb (and delete the repo/ dir).
Rollo answered 17/11, 2015 at 0:40 Comment(1)
Do we have another way instead of deleting the current repo?Denverdeny
B
5

Whenever I have hit this error it was because the branch specified in my deploy/environment.rb file wasn't checked into git. Do an add / commit / git push origin branch_name and that will likely make things work.

Bahr answered 30/9, 2016 at 8:52 Comment(0)
T
4

I think that folder gets populated via a git pull, so it shouldn't be empty. If you do see it empty the issue is from the git not the tarball.

The issue I had was my capistrano deploy.rb repository URL was set to a different one than that project i was working in. In order to fix this issue, I also had to logon to the server and delete the app_name/repo folder which must have been caching the original bad remote URL.

Tiddly answered 9/2, 2014 at 0:13 Comment(1)
for googling folks: also check if you set existing branch !!! ...worked for me :)Cullin
X
4

You can set your branch on deploy.rb with: set :branch, "main"

source

Note: the default branch is master

Xuanxunit answered 26/5, 2021 at 9:57 Comment(1)
My default was 'main' also, thank you!Length
L
0

I'm using Bedrock Roots (wordpress) for development, capistrano for deploys and git flow. Stumbled upon this error when tried to deploy, while on hotfix/x.x.x branch locally. So I finished current (merged changes to develop branch) and then successfully deployed.

Lapstrake answered 26/8, 2015 at 12:47 Comment(3)
Do you understand why merging into develop fixed your issue?Unmusical
Deploying other branches may work, but the question remains why is the particular one you're trying to deploy not working? I may have an answer.Graber
@EricFrancis Actually, I do now) As the voted answer states, hotfix didn't exist on remote (where capistrano deploys from)Lapstrake

© 2022 - 2024 — McMap. All rights reserved.