question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No files mounted when tar uses relative paths

See original GitHub issue

All the files appear to have been mounted within an unreachable ‘.’ folder, with the index file listing the them as being at locations like /./.config.

The tar.gz was generated on osx with a relative path given as well as a list of folders to exclude.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Jamedjocommented, Apr 20, 2019

Thanks!

I’d managed to get a hacky workaround but will retry with your patch.

The --recreate-index flag will come in handy and reminds me I was hoping for a “don’t recursively untar” option since this was a backup of my home directory including random tar files.

The fix I used was:

diff --git a/ratarmount.py b/ratarmount.py
old mode 100644
new mode 100755
index 89c4cd7..6d6cd83
--- a/ratarmount.py
+++ b/ratarmount.py
@@ -133,7 +133,7 @@ class IndexedTar:
                 indexedTar = IndexedTar( tarInfo.name, fileObject = fileObject, writeIndex = False )
                 fileObject.seek( fileObject.tell() ) # might be especially necessary if the .tar is not actually a tar!
 
-            path = "/" + tarInfo.name
+            path = "/" + re.sub(r"^\./", "", tarInfo.name)
 
             if indexedTar is not None and ( indexedTar.dirIndex or indexedTar.fileIndex ):
                 # actually apply the recursive tar mounting
0reactions
mxmlnkncommented, May 5, 2019

The example.tar.gz is compressed. This is currently not supported. I added a warning message and avoided mounting an empty directory in case a compressed archive is specified. I was looking into combining ratarmount with lzopfs in order to add support for compressed archives but currently I don’t have the incentive as I don’t need it.

The problem with your TAR in comparison to my self created TARs with leading ./ is that it contains ./. I.e., output for tar tvf for my test TAR:

-rw-r--r-- user   4 2019-04-19 12:38 ./bar

your test TAR:

drwxr-xr-x user 0 2019-04-20 04:52 ./
-rw-r--r-- user 8 2019-04-20 04:52 ./file
drwxr-xr-x user 0 2019-04-20 04:52 ./somefolder/
-rw-r--r-- user 2 2019-04-20 04:52 ./somefolder/file

The problematic entry being the topmost one. It seems such a TAR can be created with:

tar --owner=user --group=group -cf ../foo.tar ./

Could you test the latest commit?

Read more comments on GitHub >

github_iconTop Results From Across the Web

tar with relative paths - Unix & Linux Stack Exchange
This archives (compresses) all the given files without absolute paths. It appears that with the dot ( . ) works well. Don't know...
Read more >
Relative paths for -f are broken, and --project-directory ...
Your error message indicates, that the file you are trying to untar is actually not a tar.gz file despite its name. This can...
Read more >
use a relative path in requirements.txt to install a tar.gz file with ...
This path is not relative to the requirements.txt file, but rather to the current working directory. Therefore it is necessary to navigate ...
Read more >
[SOLVED] tar absolute and relative path - LinuxQuestions.org
i use absolute path to make a backup tar cvf backup /home/user and when i try to restore backup it doesn't destroy my...
Read more >
Linux / UNIX: tar Command Stay In Local / File System When ...
How do I force tar to use a single file system under Linux / UNIX / BSD ... the tar command not to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found