Permission denied when restoring cache in CircleCi job - linux

Whenever my job run, they always take around 40s to download and install libreoffice. I'm gonna to store this into cache and restore cache to reuse it in next job.
- restore_cache:
key: cache-libre-6.3-b # Restore libreoffice
- run:
name: install libreoffice 6.3
command: |
if [[ ! -d /opt/libreoffice6.3/ ]]; then
# download & install the .deb
mkdir -p /tmp/libreoffice
l=download.tar.gz
cd /tmp/libreoffice
wget -O $l https://download.documentfoundation.org/libreoffice/stable/6.3.3/deb/x86_64/LibreOffice_6.3.3_Linux_x86-64_deb.tar.gz
tar -xvf $l
d=`ls -td */ | head -n1`
cd $d/DEBS/
sudo dpkg -i *.deb
cd -
# install dependencies required when run :soffice binary ref. https://github.com/microsoft/vscode/issues/13089
sudo apt update
sudo apt install -y libxinerama1 libgtk2.0-0 libxss-dev libgconf-2-4 libasound2
fi
# make :libreoffice softlink to libreoffice binary 6.3
sudo ln -s /opt/libreoffice6.3/program/soffice /usr/bin/libreoffice
sudo chmod -R 777 /opt/libreoffice6.3/
- save_cache:
key: cache-libre-6.3-b
paths:
# Save cache libreoffice
- /opt/libreoffice6.3/
- /home/circleci/cache-libre
When I rerun the job again, I can not restore cache. I got some permission denied below:
Found a cache from build 7593 at cache-libre-6.3-b
Size: 271 MB
Cached paths:
* /opt/libreoffice6.3
* /home/circleci/cache-libre
Downloading cache archive...
Validating cache...
Unarchiving cache...
Failed to unarchive cache
Error untarring cache: Error extracting tarball /tmp/cache785237819 : tar: opt/libreoffice6.3: Cannot mkdir: Permission denied tar: opt/libreoffice6.3: Cannot mkdir: Permission denied tar: opt/libreoffice6.3/CREDITS.fodt: Cannot open: No such file or directory tar: opt/libreoffice6.3: Cannot mkdir: Permission denied tar: opt/libreoffice6.3/LICENSE: Cannot open: No such file or directory tar: opt/libreoffice6.3: Cannot mkdir: Permission denied tar: opt/libreoffice6.3/LICENSE.html: Cannot open: No such file or directory tar: opt/libreoffice6.3: Cannot mkdir: Permission denied tar: opt/libreoffice6.3/NOTICE: Cannot open: No such file or directory tar: opt/libreoffice6.3: Cannot mkdir: Permission denied tar: opt/libreoffice6.3/help: Cannot mkdir: No such file or directory tar: opt/libreoffice6.3: Cannot mkdir: Permission denied tar: opt/libreoffice6.3/help/a11y-toggle.js: Cannot open: No such file or directory tar: opt/libreoffice6.3: Cannot mkdir: Permission denied tar: opt/libreoffice6.3/help/default.css: Cannot open: No such file or directory tar: opt/libreoffice6.3: Cannot mkdi: exit status 2
How can I solve this.

This happened to me recently also. Given that I had many builds saving and restoring that cache using that key before it might have been intermittent and it's unlikely this was a direct cause; however, I would mention this just in case it happens to help people.
I had previously been playing with the working_directory command in attempt to use the persist-to-workspace and attach_workspace and think this could have caused the issue.
Sequence that might have caused error:
Build A:
set working directory working_directory: ~/tmp
save cache with key X
Build B:
default working directory (did not use working_directory command)
attempt to restore cache with same key X (but different working directory)
Error untarring cache: Error extracting tarball
Solution that fixed it was simply changing the cache key. Such as from v1 prefix to v2. This avoids attempting to restore cache that was made for working directory tmp to be attempted to be restored to different working directory. It now uses a fresh one.

Related

tar: can't create directory 'sqljdbc_7.2/': Permission denied tar: can't open 'sqljdbc_7.2/': Is a directory

I am trying to copy a file and then uncompress it in a docker file with these comands.
#MSSQL SERVER JDBC DRIVER INSTALL
COPY sqljdbc_7.2.2.0_enu.tar.gz /camunda/lib/
WORKDIR /camunda/lib
RUN tar -xf sqljdbc_7.2.2.0_enu.tar.gz
ENV CLASSPATH=${CLASSPATH}:/tmp/sqljdbc_7.2/enu/mssql-jdbc-7.2.2.jre11.jar
ARG CLASSPATH=${CLASSPATH}:/tmp/sqljdbc_7.2/enu/mssql-jdbc-7.2.2.jre11.jar
RUN echo $CLASSPATH
but i get this error:
tar: can't create directory 'sqljdbc_7.2/': Permission denied tar:
can't open 'sqljdbc_7.2/': Is a directory
try to use ADD this will untar the file for you:
ADD sqljdbc_7.2.2.0_enu.tar.gz /camunda/lib/
and remove the following from Dockerfile:
WORKDIR /camunda/lib
RUN tar -xf sqljdbc_7.2.2.0_enu.tar.gz
From The Docs:
If is a local tar archive in a recognized compression format
(identity, gzip, bzip2 or xz) then it is unpacked as a directory.

Failing to run wkhtmltopdf on shared host

This is the first time I am using wkhtmltopdf.
Works fine on my Windows local pc, but I can't make it work on the live Linux shared host server.
I tried all kinds of solutions I found on google but nothing works.
I am a windows user, so I don't know anything about Linux, but I do have SSH access to the host server and the host confirmed that this is the right file to use on their server.
First I got the file, and then I tried to extract it with no success:
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
tar xvjf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
bzip2: (stdin) is not a bzip2 file.
tar: Child returned status 2
tar: Error is not recoverable: exiting now
tar -xvjf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
bzip2: (stdin) is not a bzip2 file.
tar: Child returned status 2
tar: Error is not recoverable: exiting now
tar xvJf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
tar (child): xz: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
So I extracted the file on my local windows machine.
I manually created these folders on the host server:
usr/local/bin.
I uploaded the 2 binaries files from my local machine to this bin folder.
And I tried a few ways to test it:
./wkhtmltopdf-amd64 http://www.example.com example.pdf
-bash: ./wkhtmltopdf-amd64: No such file or directory
/wkhtmltopdf-amd64 http://www.example.com ex.pdf
-bash: /wkhtmltopdf-amd64: No such file or directory
./wkhtmltopdf http://www.example.com ex.pdf
-bash: ./wkhtmltopdf: No such file or directory
/wkhtmltopdf http://www.example.com ex.pdf
-bash: /wkhtmltopdf: No such file or directory
Please, can someone help me make this work?
Make sure wkhtmltopdf binary has executable permission. Assuming you have copied them into /usr/local/bin
chmod +x /usr/local/bin/wkhtmltopdf
then run
/usr/local/bin/wkhtmltopdf --version

create new script to tar file return error

I've create script which (under the root folder on my machine) , to create two folder and take from the root folder
tar file and extract it in specified folder, the problem is that i`m getting error(not found in archive
tar: Exiting with failure status due to previous errors), Im new to scripting ...
The tar is under the root
this is my script
#!/bin/bash
mkdir aa_tmp
mkdir bb_myBP
tar -xvf /home/i079900/aiab-cdi-ui-assembly.tar /home/i079900/bb_myBP
echo "success"
I want that after the folder bb_myBP is created to extract this file in the bb_myBP
all folder and assets are under /home/i079900, any idea what I miss here?
the tar file is located under my user ...
So you want to extract the files to he newly created directory bb_myBp?
tar command needs a -C argument to determine which directory to extract.
#!/bin/bash
mkdir aa_tmp
mkdir bb_myBP
tar -xvf /home/i079900/aiab-cdi-ui-assembly.tar -C
/home/i079900/bb_myBP
echo "success"

tar (child): phpMyAdmin-3.4.1-all-languages-tar.bz2: Cannot open: No such file or directory

I'm using amazon web services for the first time, I'm using the ec2 Amazon Linux instance for this. What I want to do is, I want to install PhpmyAdmin over there, so for that first of all I have already installed php, mysql and apache. After that I was trying to install phpmyAdmin. So for that I fired following commands:
cd /var/www/html
sudo chown ec2-user
wget http://www.sourceforge.net/projects/phpmyadmin/files/phpMyAdmin/3.4.1/phpMyAdmin-3.4.1-all-languages.tar.bz2
So after this I tried to extract phpmyadmin with following command
tar -jxf phpMyAdmin-3.4.1-all-languages-tar.bz2 -C /var/www/html
After firing that command I got the following errors:
tar (child): phpMyAdmin-3.4.1-all-languages-tar.bz2: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
Please help me out with this :-). Every comments and helps are appreciated :-). Thanks in advance.
Have you tried adding ./ before the filename to indicate the file is located in the current directory?
tar -jxf ./phpMyAdmin-3.4.1-all-languages-tar.bz2 -C /var/www/html
tar -jxf phpMyAdmin-3.4.1-all-languages.tar.bz2
This command worked.

tar: Error is not recoverable: exiting now

when I untar doctrine
-rw-r--r-- 1 root root 660252 2010-10-16 23:06 Doctrine-1.2.0.tgz
I always get this error messages
root#X100e:/usr/local/lib/Doctrine/stable# tar -xvzf Doctrine-1.2.0.tgz
.
.
.
Doctrine-1.2.0/tests/ViewTestCase.php
Doctrine-1.2.0/CHANGELOG
gzip: stdin: decompression OK, trailing garbage ignored
Doctrine-1.2.0/COPYRIGHT
Doctrine-1.2.0/LICENSE
tar: Child returned status 2
tar: Error is not recoverable: exiting now
The untar operation works, but I always get this error messages.
Any clues what I do wrong?
I would try to unzip and untar separately and see what happens:
mv Doctrine-1.2.0.tgz Doctrine-1.2.0.tar.gz
gunzip Doctrine-1.2.0.tar.gz
tar xf Doctrine-1.2.0.tar
It's possible your tar file is not zipped. I just had this same error, but all I had was a plain old tar file. So try just removing the z from your flags. The z flag unzips your tar file as well as whatever other commands you requested with other flags. i.e. try:
tar -xvf Doctrine-1.2.0.tgz
Notice I removed the z from -xvzf
If you got "Error is not recoverable: exiting now" You might have specified incorrect path references.
[me#host ~]$ tar -xvf nameOfMyTar.tar -C /someSubDirectory/
tar: /someSubDirectory: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
[me#host ~]$
Make sure you provide correct relative or absolute directory references e.g.:
[me#host ~]$ tar -xvf ./nameOfMyTar.tar -C ./someSubDirectory/
./foo/
./bar/
[me#host ~]$
Try to get your archive using wget, I had the same issue when I was downloading archive through browser. Than I just copy archive link and in terminal use the command:
wget http://PATH_TO_ARCHIVE
The problem is that you do not have bzip2 installed. The tar program relies upon this external program to do compression.
For installing bzip2, it depends on the system you are using. For example, with Ubuntu that would be on Ubuntu
sudo apt-get install bzip2
The GNU tar program does not know how to compress an existing file such as user-logs.tar (bzip2 does that). The tar program can use external compression programs gzip, bzip2, xz by opening a pipe to those programs, sending a tar archive via the pipe to the compression utility, which compresses the data which it reads from tar and writes the result to the filename which the tar program specifies.
Alternatively, the tar and compression utility could be the same program. BSD tar does its compression using lib archive (they're not really distinct except in name).
use sudo
sudo tar -zxvf xxxxxxxxx.tar.gz
Error messages
Easy way to fix this issue
First Remove files
Download file again
Extract file again ( tar -xzvf(or -xvf) FreeFileSync**.tar.gz
Had the same error code:
tar -xvfz processed.json.gz
tar: z: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
Turned out the file had the .gz extension but wasn't compressed. Just removed the .gz and opened it.

Resources