Repository: easybuilders/easybuild-framework

Issue:
piped tar fails if $TAPE is defined
The error came up when I tried the following installation, but the problem seems to be any piped tar (i.e. stdin and/or stdout) when `$TAPE` is defined -- tar uses this as a default name:
( https://www.gnu.org/software/tar/manual/html_chapter/Media.html#Device )

At Cineca, `$TAPE` points to the tape archive directory.

Simple solution, `(unset TAPE; eb ...)`
But in principle, `eb` could check that `$TAPE` is not set.

```eb NVHPC-21.2.eb --robot
== Temporary log file in case of crash /tmp/eb-pbm6_fr6/easybuild-3vot8f76.log
== found valid index for /m100/home/userexternal/thayward/easybuild/software/EasyBuild/4.3.4/easybuild/easyconfigs, so using it...
== resolving dependencies ...
== found valid index for /m100/home/userexternal/thayward/easybuild/software/EasyBuild/4.3.4/easybuild/easyconfigs, so using it...
== processing EasyBuild easyconfig /m100/home/userexternal/thayward/easybuild/software/EasyBuild/4.3.4/easybuild/easyconfigs/h/help2man/help2man-1.47.4.eb
== building and installing help2man/1.47.4...
== fetching files...
== creating build dir, resetting environment...
== unpacking...
== FAILED: Installation ended unsuccessfully (build directory: /dev/shm/thay/eb/help2man/1.47.4/system-system): build failed (first 300 chars): cmd "unxz /m100_work/FUSIO_ru4IPP_0/thayward/eb/sources/h/help2man/help2man-1.47.4.tar.xz --stdout | tar x" exited with exit code 2 and output:
tar: /gss/gss_work/tape/userexternal/thayward: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
 (took 0 sec)
== Results of the build can be found in the log file(s) /tmp/eb-pbm6_fr6/easybuild-help2man-1.47.4-20210414.164654.ckhvW.log
ERROR: Build of /m100/home/userexternal/thayward/easybuild/software/EasyBuild/4.3.4/easybuild/easyconfigs/h/help2man/help2man-1.47.4.eb failed (err: 'build failed (first 300 chars): cmd "unxz /m100_work/FUSIO_ru4IPP_0/thayward/eb/sources/h/help2man/help2man-1.47.4.tar.xz --stdout | tar x" exited with exit code 2 and output:\ntar: /gss/gss_work/tape/userexternal/thayward: Cannot open: No such file or directory\ntar: Error is not recoverable: exiting now\n')```


Discussion:

Resolving patch:
diff --git a/easybuild/tools/filetools.py b/easybuild/tools/filetools.py
--- a/easybuild/tools/filetools.py
+++ b/easybuild/tools/filetools.py
@@ -141,9 +141,11 @@
     '.tb2': "tar xjf %(filepath)s",
     '.tbz': "tar xjf %(filepath)s",
     '.tbz2': "tar xjf %(filepath)s",
-    # xzipped or xzipped tarball
-    '.tar.xz': "unxz %(filepath)s --stdout | tar x",
-    '.txz': "unxz %(filepath)s --stdout | tar x",
+    # xzipped or xzipped tarball;
+    # need to make sure that $TAPE is not set to avoid 'tar x' command failing,
+    # see https://github.com/easybuilders/easybuild-framework/issues/3652
+    '.tar.xz': "unset TAPE; unxz %(filepath)s --stdout | tar x",
+    '.txz': "unset TAPE; unxz %(filepath)s --stdout | tar x",
     '.xz': "unxz %(filepath)s",
     # tarball
     '.tar': "tar xf %(filepath)s",


Test patch:
diff --git a/test/framework/filetools.py b/test/framework/filetools.py
--- a/test/framework/filetools.py
+++ b/test/framework/filetools.py
@@ -92,8 +92,8 @@ def test_extract_cmd(self):
             ('untar.gz', "gunzip -c untar.gz > untar"),
             ("/some/path/test.gz", "gunzip -c /some/path/test.gz > test"),
             ('test.xz', "unxz test.xz"),
-            ('test.tar.xz', "unxz test.tar.xz --stdout | tar x"),
-            ('test.txz', "unxz test.txz --stdout | tar x"),
+            ('test.tar.xz', "unset TAPE; unxz test.tar.xz --stdout | tar x"),
+            ('test.txz', "unset TAPE; unxz test.txz --stdout | tar x"),
             ('test.iso', "7z x test.iso"),
             ('test.tar.Z', "tar xzf test.tar.Z"),
             ('test.foo.bar.sh', "cp -a test.foo.bar.sh ."),