2

I am getting the following error when my bash script executes tar -xf

[21:02:51][Step 2/2] tar (child): lbzip2: Cannot exec: No such file or directory
[21:02:51][Step 2/2] tar (child): Error is not recoverable: exiting now
[21:02:51][Step 2/2] tar: Child returned status 2
[21:02:51][Step 2/2] tar: Error is not recoverable: exiting now
[21:02:51][Step 2/2] Process exited with code 2

I did check that I had bzip2 installed (as suggested in this answer):

enter image description here

Not quite sure if I need bzip2-libs:

enter image description here

The weird thing is, when I run the script manually from sh, it runs fine! But when I run it via TeamCity (which is running in Docker), it fails with the above error.

The script is literally the following (omitting some details):

#!/bin/bash
whoami
echo "$USER"
set -e
ScriptFilename=$0
ScriptPath=$(cd $(dirname $0) && pwd)

argn=$#
if [[ $argn != '1' ]]; then
    echo "usage: ${ScriptFilename} phpArchivesDirTarFile"
    exit
fi

phpArchivesDirTarFile=$1

function ExtractPhpArchives {       
    tar -C $ScriptPath -xf $phpArchivesDirTarFile
}

echo "ExtractPhpArchives"
ExtractPhpArchives

It results in the following TeamCity output:

enter image description here

Suspecting a permissions problem, I added "whoami" (which prints "root") and echo "$USER" which, a bit surprisingly, prints nothing.

What's more interesting, I have a backup copy or the tar file for which the script runs fine in TeamCity. But when I extracted the tarball contents and archived them again, I was back to the "Cannot exec" problem:

enter image description here

TeamCity settings:

enter image description here

Why am I getting this error and what else can I try to debug it?

Sergey Slepov
  • 1,861
  • 13
  • 33

0 Answers0