Repository navigation
Conversation
The `exploded_zip` extractor creates a symlink with `os.symlink`, which does not create the directory the link is in. That directory exists only if the archive has an entry for it or for a regular file in it. For a directory that holds only symlinks, in an archive without directory entries, the action failed with `FileNotFoundError`. `zip -ryD` writes such an archive, as does `zip -y -@` with a list of files, and `unzip` extracts it. The directory is now created before the link.
Contributor
|
This pull request has been imported. If you are a Meta employee, you can view this in D134892171. (Because this pull request was imported automatically, there will not be any future comments.) |
Contributor
|
This pull request has been merged in 1fe7822. |
meta-codesync Bot
pushed a commit
to meta/buck2-prelude
that referenced
this pull request
Nov 28, 2026
Summary: `remote_file(type = "exploded_zip")` extracts with `prelude/zip_file/tools/unzip.py`. The script creates a symlink with `os.symlink`, which does not create the directory the link is in. That directory exists only if the archive has an entry for it or for a regular file in it. For a directory that holds only symlinks, in an archive without directory entries, the action fails with `FileNotFoundError`. This PR creates the directory before the link. ## Affected version origin/main 2099e8f075. ## Reproduction ``` mkdir -p src/pkg src/bin && echo x > src/pkg/cli.js && ln -s ../pkg/cli.js src/bin/tool (cd src && zip -qryD ../a.zip .) python3 prelude/zip_file/tools/unzip.py --src a.zip --dst out ``` `-D` leaves out directory entries; `find . -type f -o -type l | zip -qy ../a.zip -@` gives the same archive. ## Expected `out/bin/tool` is a link to `../pkg/cli.js`, as with `unzip a.zip -d out`. ## Actual ``` FileNotFoundError: [Errno 2] No such file or directory: '../pkg/cli.js' -> 'out/bin/tool' ``` X-link: meta/buck2#1673 Reviewed By: dtolnay Differential Revision: D134892171 fbshipit-source-id: da8247f1c4487d24f05361a3a7c2abd8e259ce6f
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
remote_file(type = "exploded_zip")extracts withprelude/zip_file/tools/unzip.py. The script creates a symlink withos.symlink, which does not create the directory the link is in. That directory exists only if the archive has an entry for it or for a regular file in it. For a directory that holds only symlinks, in an archive without directory entries, the action fails withFileNotFoundError.This PR creates the directory before the link.
Affected version
origin/main 2099e8f.
Reproduction
-Dleaves out directory entries;find . -type f -o -type l | zip -qy ../a.zip -@gives the same archive.Expected
out/bin/toolis a link to../pkg/cli.js, as withunzip a.zip -d out.Actual
Test plan
prelude/zip_file/tools/tests/test_unzip.py: the newtest_a_symlink_in_a_directory_without_an_entry_is_extractedfails with theFileNotFoundErrorwithout the change and passes with it. The other four tests pass.zip -ryDand byzip -y -@(Info-ZIP 3.0): the link is created and reads through to the file.remote_filetarget.