rattler-build icon indicating copy to clipboard operation
rattler-build copied to clipboard

fix: add tolerant tar extraction on windows to solve failing on symlinks

Open Krande opened this issue 1 year ago • 10 comments

Hey guys,

this is supposed to close https://github.com/prefix-dev/rattler-build/issues/940.

This is my first time writing rust beyond just "hello world", so any suggestions for improvements are most welcome!

Krande avatar Oct 26 '24 14:10 Krande

Thank you! On first glance, looks good!

wolfv avatar Oct 26 '24 14:10 wolfv

@wolfv i think I've fixed the linting issue. Let me know if there is anything else I should consider.

Krande avatar Oct 28 '24 13:10 Krande

Hi @Krande - let me know if you want to make the changes or if you would prefer me taking over :)

wolfv avatar Oct 29 '24 17:10 wolfv

If you have time to implement the changes, feel free to finish them:) if not, I'll likely start to implement them after lunch time tomorrow!

Krande avatar Oct 29 '24 18:10 Krande

I looked a little bit deeper and I think unfortunately this doesn't cover a bunch of (other) edge cases that the original tar extraction code covers. That's really unfortunate. Ideally we could implement this kind of behavior / filtering in tar-rs directly.

wolfv avatar Oct 29 '24 18:10 wolfv

I see. I checked tar-rs and found this https://github.com/alexcrichton/tar-rs/issues/280 which I guess is related.

Krande avatar Oct 30 '24 06:10 Krande

Would it be possible to make this tolerant extraction feature optional by hiding it behind an opt-in flag until a better long-term solution can be found?

That way, it is at least possible for us forced to use windows in our day jobs to use rattler-build for projects containing symlinks :)

Krande avatar Oct 30 '24 13:10 Krande

A "shitty" workaround is to keep the source as tarball. This is possible since the last release or two by adding a option:

file_name: source.tar.gz

Then you can add e.g. 7zip to your build dependencies, and extract the source code during the build step.

Is that an OKish workaround? Sorry for not coming up with something better. I would love an option in the tar crate. Maybe you could also work on a PR over there?

wolfv avatar Nov 17 '24 12:11 wolfv

Is that an OKish workaround?

Yeah, anything that works is fine for now :) That at least gives me a chance at using rattler-build for more packages :)

Maybe you could also work on a PR over there?

Sure, I can try. It would also help if you can shed some light on the types of edge cases a filtering behaviour in tar-rs should be able to cover? Referring to your comment

I looked a little bit deeper and I think unfortunately this doesn't cover a bunch of (other) edge cases that the original tar extraction code covers.

Krande avatar Nov 17 '24 17:11 Krande

@Krande I think if you add this behavior to the original tar, then we can keep using the existing unextract functionality that covers all the edge cases. But we can just gracefully warn instead of fail when we cannot create a symlink.

You could add a SymlinkBehavior enum to tar-rs and have Fail, Warn or Copy options and then implement them accordingly when symlinking fails.

wolfv avatar Nov 17 '24 19:11 wolfv