WSL icon indicating copy to clipboard operation
WSL copied to clipboard

tar with symbolic links

Open tinysun212 opened this issue 10 years ago • 50 comments

I could create a symbolic links by ln -s.

root@localhost:~# ls -l kkk
total 0
-rw-rw-rw- 1 root root 14 Apr  7 04:53 atest
lrwxrwxrwx 1 root root  5 Apr  7 04:54 btest -> atest

But I can't archive with the tar.

root@localhost:~# tar cvf kkk.tar kkk
kkk/
kkk/atest
tar: kkk/btest: Cannot readlink: Invalid argument
tar: Exiting with failure status due to previous errors

In reverse, the symbolic links in a tar file which built on Linux can't be extracted.

tinysun212 avatar Apr 07 '16 05:04 tinysun212

Related to #3 and/or #6 ?

jokeyrhyme avatar Apr 07 '16 05:04 jokeyrhyme

The error messages are different.

In my case, ln -s is working, but not compatible with tar.

Here is the reverse operation output. ( extracting symlinks-containing tar whilch is built on real Linux )

root@localhost:~# tar tvf /mnt/c/temp/kkk.tar
drwxr-xr-x root/root         0 2016-04-07 05:25 kkk/
lrwxrwxrwx root/root         0 2016-04-07 05:25 kkk/btest -> atest
-rw-r--r-- root/root        12 2016-04-07 05:24 kkk/atest
root@localhost:~# tar xvf /mnt/c/temp/kkk.tar
kkk/
kkk/btest
tar: kkk/btest: Cannot create symlink to ‘atest’: Invalid argument
kkk/atest
tar: Exiting with failure status due to previous errors

tinysun212 avatar Apr 07 '16 05:04 tinysun212

I can echo this: I tried to install rvm from get.rvm.io and the script crashes and burns because of the tar symlink incompatibility.

hfaran avatar Apr 07 '16 08:04 hfaran

I also can confirm this. (Running on 64-bit, on the off chance that matters). Can create symlinks just fine, cannot tar them or untar packages which contain them. As an interesting consequence, apt packages which contain symlinks (Java) also cannot be installed.

mphaney avatar Apr 07 '16 15:04 mphaney

I was trying to copy files from a real linux box using tar. Also running into the symlink issue. As a workaround I was able to copy the files using bsdtar which creates symlinks correctly.

christoh avatar Apr 07 '16 15:04 christoh

This is affecting http://nvm.sh installs via windows as well. https://github.com/creationix/nvm/issues/1054

ljharb avatar Apr 07 '16 20:04 ljharb

This might relate to is #44 as well...for me anyway, the move won't work on tarballs/zips from CPAN which contain soft links.

jbaribeault avatar Apr 07 '16 21:04 jbaribeault

+1. Can't install Meteor due to this issue. Copying the files from a Linux VM sort of works if you re-create the tarball with the h option (i.e. tar cvfh).

tomgrek avatar Apr 08 '16 18:04 tomgrek

As @ljharb said: nvm doesn't install properly. And none of the tools that uses symlinks with tar works right now.

filipeaguiar avatar Apr 09 '16 01:04 filipeaguiar

To clarify, this is affecting nvm's ability to install node. nvm itself installs fine.

ljharb avatar Apr 09 '16 02:04 ljharb

because of this error i am not able to install rbenv

julihermes avatar Apr 09 '16 18:04 julihermes

The tar extraction problem with symlinks is caused by the missing symlinkat syscall (symlink was supported but not the at variant). This bug has been fixed internally.

Similarly, I believe creating a tar file with symlinks fails because readlinkat is missing.

SvenGroot avatar Apr 10 '16 03:04 SvenGroot

Just as a note if someone else stumbles upon this: this also affects installation of Miniconda using Continuum Analytics Miniconda installation shell script that extracts a tar archive containing symlinks.

You get errors like this:

tar: bin/2to3: Cannot create symlink to ‘2to3-3.5’: Invalid argument

boulund avatar Apr 10 '16 07:04 boulund

Having the same trouble installing RVM. I can download the zip version and install manually, but I get a warning at the end of the install:

* WARNING: you are missing '/dev/fd' it is important for shell scripting used by RVM, You can fix it on most linux systems with: ln -sf /proc/self/fd /dev/fd

/proc/self/fd does exist, but following those instructions gives me:

root@localhost:~# ln -s /proc/self/fd /dev/fd ln: failed to create symbolic link ‘/dev/fd’: Operation not permitted

This is a different error. I make a note here wondering if the (internal) fix would address this, or if we're into some unsupported behavior in the /proc filesystem now.

I got RVM installed manually, but, of course, it wants to install rubies from tar-ed sources, which loops me back around to the original problem, and I'm tired of fighting it.

davidkrider avatar Apr 10 '16 12:04 davidkrider

DunKirk, that error is due to some limitations of our /dev filesystem that prevent you from creating a link there. We're working to address this. This is separate from the symlinkat error.

SvenGroot avatar Apr 10 '16 19:04 SvenGroot

@SvenGroot thank you much!

MadcowD avatar Apr 10 '16 23:04 MadcowD

I have an example where openat() on a symlink returns no such file or directory despite the symlink existing but not the target. Does the symlinkat fix also apply here?

# e.g. openat("libsolv.so") fails with no such file or directory
root@localhost:# ls -l
total 0
lwrxwrxwrx 1 root root 12 Apr 10 23:33 libsolv.so -> libsolv.so.1
root@localhost:#

Example: https://github.com/haiku/haiku/blob/master/src/bin/package/command_extract.cpp#L552

jessicah avatar Apr 11 '16 00:04 jessicah

Thanks for the feedback. Support for both symlinkat and readlinkat has been added to the code, but the build has not made it to flighting yet.

sunilmut avatar Apr 11 '16 22:04 sunilmut

Is there some kind of workaround for this?

EdoaLive avatar Apr 12 '16 08:04 EdoaLive

Thanks for the feedback. Support for both symlinkat and readlinkat has been added to the code, but the build has not made it to flighting yet.

@sunilmut - any idea about when the new build will be released? Is there a release plan hidden somewhere? :wink:

perlun avatar Apr 12 '16 11:04 perlun