fix: skip unpacking symlinks on Windows instead of failing#2454
Conversation
|
Having a clear error is nice, but maybe even just continuing would be even nicer. In rattler/pixi we try to unpack symlinks, and if they fail, we simply ignore them and issue a warning. I think that behavior would also be fine here. If it's a problem that they are missing, you will find out soon enough during the build itself. Another option that we could pursue instead is to create a symlink, and if that fails, we simply materialize/create a copy of the file. |
|
@baszalmstra I think both alternatives are better UX than a hard failure.
It is simpler to implement - the
This approach is more robust - if the symlink target exists in the archive, we can materialise it as a regular file. The extracted tree is functionally complete even without actual symlinks. I'd lean towards the copy fallback since it's transparent to the build, but it does require iterating tar entries manually and tracking regular files as they're extracted so we can copy them when a symlink to them is encountered. Happy to implement whichever approach you prefer. |
|
@baszalmstra Looking forward to your thoughts/opinions on my ideas above. Thank you. <3. |
|
Hi @baszalmstra. Waiting for your response. Thank you. |
|
I like the copy fallback the most as well but it might be slightly tricky if there are symlinks to files that do not (yet) exist, because the order of extraction now matters. Id say we go with warn and skip first. |
|
See this part in rattler where we implement this behavior for extraction: |
On Windows, creating symlinks requires Developer Mode or administrator privileges. Rather than failing the entire extraction when a symlink entry cannot be unpacked, iterate tar entries manually and skip failing symlinks with a warning. The rest of the archive is extracted normally; any missing symlink will surface as a build error only if it is actually needed.
|
@baszalmstra I have implemented the warn and skip approach. Please take a look whenever you get a chance. Thank you. |
Problem
Refer - #940 (comment)
When rattler-build tries to extract a source archive (e.g. a
.tar.gz) that contains symbolic links on Windows without Developer Mode enabled, the extraction fails hard with no actionable information:Solution
Instead of failing the entire extraction when a symlink cannot be created, this PR iterates tar entries manually and skips failing symlink entries with a warning on Windows. The approach mirrors what rattler/pixi already do for their own extraction path.
unpack_tar_entrieshelper - replaces the singlearchive.unpack(target)call across all compression formats (.tar.gz,.tar.bz2,.tar.xz,.tar.zst, plain.tar) with a manual entry loop. On Windows, if unpacking a symlink entry fails, atracing::warn!is emitted and extraction continues. Any other error still propagates as before.No registry access or new dependencies - no
winreg, nowindows-sys, nounsafe. The fix is pure platform-conditional Rust.Test coverage - a Windows-only test (
test_symlink_extraction_skipped_on_windows) creates a minimal.tar.gzwith a symlink entry and asserts thatextract_tarsucceeds regardless of Developer Mode status.Notes
#[cfg(target_os = "windows")]block is a no-op on other platforms and all other errors still fail extraction.