SharpCompress hangs when tar contains symbolic link and is not possible to create it #360

Open
opened 2026-01-29 22:10:40 +00:00 by claunia · 8 comments
Owner

Originally created by @justalemon on GitHub (Aug 8, 2019).

I was currently working on one of my programs when I tried to extract a .tar.xz (you can get it from here) and the WriteEntryToDirectory call ended up hanging on a specific file:

image

Just to make sure that I didn't made a mistake on my code, I tried to extract the file with WinRAR and it warned me that it was not possible to create a symbolic link:

image

Unable to create the symbolic link C:\Users\lemon\AppData\Local\Temp\Rar$DRa13524.1044\alpine\usr\share\terminfo\l\linux
Maybe you need to execute WinRAR with administrator permissions.

Maybe SharpCompress is not handling symbolic links errors correctly?

Originally created by @justalemon on GitHub (Aug 8, 2019). I was currently working on one of my programs when I tried to extract a `.tar.xz` (you can get it from [here](https://runtime.fivem.net/artifacts/fivem/build_proot_linux/master/1462-ba3c7493bf62c6fab054987761c41d3b6c696889/)) and the WriteEntryToDirectory call ended up hanging on a specific file: ![image](https://user-images.githubusercontent.com/11861253/62694967-5d70eb80-b9a3-11e9-8cf8-000f2681514e.png) Just to make sure that I didn't made a mistake on my code, I tried to extract the file with WinRAR and it warned me that it was not possible to create a symbolic link: ![image](https://user-images.githubusercontent.com/11861253/62695126-b0e33980-b9a3-11e9-8ec8-dfbc5fb468f0.png) > Unable to create the symbolic link C:\Users\lemon\AppData\Local\Temp\Rar$DRa13524.1044\alpine\usr\share\terminfo\l\linux > Maybe you need to execute WinRAR with administrator permissions. Maybe SharpCompress is not handling symbolic links errors correctly?
claunia added the bugup for grabs labels 2026-01-29 22:10:40 +00:00
Author
Owner

@justalemon commented on GitHub (Aug 8, 2019):

Looks like this is related to either Mono or WSL/Ubuntu. On Windows you get:

SharpCompress.Common.ExtractionException: 'Entry is a symbolic link but ExtractionOptions.WriteSymbolicLink delegate is null'

@justalemon commented on GitHub (Aug 8, 2019): Looks like this is related to either Mono or WSL/Ubuntu. On Windows you get: >SharpCompress.Common.ExtractionException: 'Entry is a symbolic link but ExtractionOptions.WriteSymbolicLink delegate is null'
Author
Owner

@adamhathcock commented on GitHub (Aug 20, 2019):

Anymore detail? Maybe this is a simple bug? I use a MacOS so I haven't tried to reproduce this.

@adamhathcock commented on GitHub (Aug 20, 2019): Anymore detail? Maybe this is a simple bug? I use a MacOS so I haven't tried to reproduce this.
Author
Owner

@RealOrko commented on GitHub (May 21, 2020):

Just found the same thing using v0.25.0 on Fedora 31.

SharpCompress.Common.ExtractionException: Entry is a symbolic link but ExtractionOptions.WriteSymbolicLink delegate is null
   at SharpCompress.Common.ExtractionMethods.WriteEntryToFile(IEntry entry, String destinationFileName, ExtractionOptions options, Action`2 openAndWrite)

By settings up the options as follows it stopped throwing an exception:

var opt = new ExtractionOptions {
   ExtractFullPath = true,
   Overwrite = true,
   WriteSymbolicLink = (source, target) => {} 
};

After doing a little investigation it would seem there is no clear way of dealing with this in the DOTNET Runtime until this issue is solved.

@RealOrko commented on GitHub (May 21, 2020): Just found the same thing using v0.25.0 on Fedora 31. ``` SharpCompress.Common.ExtractionException: Entry is a symbolic link but ExtractionOptions.WriteSymbolicLink delegate is null at SharpCompress.Common.ExtractionMethods.WriteEntryToFile(IEntry entry, String destinationFileName, ExtractionOptions options, Action`2 openAndWrite) ``` By settings up the options as follows it stopped throwing an exception: ```csharp var opt = new ExtractionOptions { ExtractFullPath = true, Overwrite = true, WriteSymbolicLink = (source, target) => {} }; ``` After doing a little investigation it would seem there is no clear way of dealing with this in the DOTNET Runtime until [this issue](https://github.com/dotnet/runtime/issues/24271) is solved.
Author
Owner

@adamhathcock commented on GitHub (May 22, 2020):

Added default delegate in https://www.nuget.org/packages/sharpcompress/0.25.1

@adamhathcock commented on GitHub (May 22, 2020): Added default delegate in https://www.nuget.org/packages/sharpcompress/0.25.1
Author
Owner

@RealOrko commented on GitHub (May 24, 2020):

@justalemon can you provide a specimen demonstrating the problem? I am currently using this library to download tars from all over github and have found it works across fedora 31/32 && ubuntu(bionic).

@RealOrko commented on GitHub (May 24, 2020): @justalemon can you provide a specimen demonstrating the problem? I am currently using this library to download tars from all over github and have found it works across fedora 31/32 && ubuntu(bionic).
Author
Owner

@RealOrko commented on GitHub (May 24, 2020):

@adamhathcock is there any appetite to add an implementation that delegates to the OS in the absence of https://github.com/dotnet/runtime/issues/24271?

@RealOrko commented on GitHub (May 24, 2020): @adamhathcock is there any appetite to add an implementation that delegates to the OS in the absence of https://github.com/dotnet/runtime/issues/24271?
Author
Owner

@justalemon commented on GitHub (May 24, 2020):

@RealOrko I got the files from https://runtime.fivem.net/artifacts/fivem/build_proot_linux/master/ they contain entire Alpine distros using symbolic links.

@justalemon commented on GitHub (May 24, 2020): @RealOrko I got the files from https://runtime.fivem.net/artifacts/fivem/build_proot_linux/master/ they contain entire Alpine distros using symbolic links.
Author
Owner

@RealOrko commented on GitHub (May 24, 2020):

@justalemon I downloaded and unzipped image 2479, 2478 and 2477 without any issues on fedora 32.

I extracted the archive twice:

  • Once using code here.
  • The second time using the command tar -xvf ./fx.tar.xz -C ./fx

I then did a search for the symlink from your screen shot ./alpine/usr/share/terminfo/... but there wasn't any to be found in either of the extracted archives. Are you doing anything special to try and create the symlinks in your code? Once thing to try might be running your unzipping code through a console app without a GUI just to be sure that there is nothing in the UI that is blocking the unzipping process when it reports status.

@RealOrko commented on GitHub (May 24, 2020): @justalemon I downloaded and unzipped image [2479](https://runtime.fivem.net/artifacts/fivem/build_proot_linux/master/2479-d086fc1a25b4ce56a8694e4baf7532905f56e161/fx.tar.xz), [2478](https://runtime.fivem.net/artifacts/fivem/build_proot_linux/master/2478-c936da7c3cd1d508425ea7a3c7ef11bc3defb3b7/fx.tar.xz) and [2477](https://runtime.fivem.net/artifacts/fivem/build_proot_linux/master/2477-e0ee8df99f6a72d688f80b409b8f3e979be8e72a/fx.tar.xz) without any issues on fedora 32. I extracted the archive twice: - Once using code [here](https://github.com/RealOrko/dotnet-cli-ghinstaller/blob/fa9f37919d46090cd77601d1d6e497c885ec8750/src/ghinstaller/Modules/Archiving/Archive.cs#L16-L61). - The second time using the command `tar -xvf ./fx.tar.xz -C ./fx` I then did a search for the symlink from your screen shot `./alpine/usr/share/terminfo/...` but there wasn't any to be found in either of the extracted archives. Are you doing anything special to try and create the symlinks in your code? Once thing to try might be running your unzipping code through a console app without a GUI just to be sure that there is nothing in the UI that is blocking the unzipping process when it reports status.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#360