Skip to content

fix(Archive::Zip): add extractToFileNamed and honor Perl chdir for jcpan -t MP3::Tag#594

Merged
fglock merged 1 commit intomasterfrom
fix/archive-zip-mp3tag
Apr 28, 2026
Merged

fix(Archive::Zip): add extractToFileNamed and honor Perl chdir for jcpan -t MP3::Tag#594
fglock merged 1 commit intomasterfrom
fix/archive-zip-mp3tag

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Apr 28, 2026

Summary

Fixes jcpan -t MP3::Tag (and any zip-distributed CPAN module) failing with Had problems unarchiving. Please build manually.

Two bugs in Archive::Zip:

  1. Missing extractToFileNamed — CPAN's CPAN::Tarzip::unzip calls $member->extractToFileNamed($af) for each archive member. PerlOnJava's Archive::Zip::Member did not implement this method, so unzip died and CPAN bailed out before the source was extracted.
  2. Relative paths ignored Perl chdir — Extraction methods used Paths.get(name) directly. Java resolves relative paths against the JVM's user.dir field, while PerlOnJava chdir only updates the user.dir system property. CPAN chdirs into a fresh tmp-$$ directory before unzipping, so files were silently being written to the launch directory and CPAN saw an empty build dir.

Added resolvePath() helper that resolves relative paths against System.getProperty("user.dir"), and applied it in extractMember, extractMemberWithoutPaths, extractTree, the new extractToFileNamed, addFile, read, and writeToFileNamed.

After this fix, jcpan -t MP3::Tag configures, builds, and runs the full test suite (Files=6, Tests=390). The remaining MP3::Tag test failures are pre-existing PerlOnJava limitations (regex lookbehind > 255, a separate NPE in some string handling) and out of scope here.

Test plan

  • make (full unit test suite) passes
  • jcpan -t MP3::Tag no longer reports "Had problems unarchiving"; t/interpolate.t, t/parser.t, t/update_tags.t, t/v2_comments.t now pass
  • Build dir ~/.cpan/build/ILYAZ-*/ now contains the actual unpacked sources

Generated with Devin

Two issues prevented `jcpan -t MP3::Tag` (and any zip-distributed CPAN
module) from being unpacked by CPAN::Tarzip::unzip:

1. Archive::Zip::Member::extractToFileNamed was not implemented, so
   CPAN::Tarzip::unzip died with "Can't locate object method
   extractToFileNamed". CPAN reported "Had problems unarchiving."

2. The extraction methods used Paths.get(name) directly, which resolves
   relative paths against the JVM's working directory. PerlOnJava's
   chdir only updates System "user.dir", not the JVM cwd, so files
   were being written to the launch directory instead of the build
   tmp-$$ directory CPAN had chdir'd into. The build dir ended up
   empty and CPAN proceeded as if the package had no Makefile.PL.

Add a resolvePath helper that resolves relative paths against
"user.dir" and use it in extractMember, extractMemberWithoutPaths,
extractTree, extractToFileNamed, addFile, read, and writeToFileNamed.

After this fix `jcpan -t MP3::Tag` actually configures, builds, and
runs the test suite. Some tests still fail due to unrelated regex
lookbehind limits and a separate NPE in string handling, but the
distribution is no longer dead-on-arrival.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@fglock fglock force-pushed the fix/archive-zip-mp3tag branch from 54402df to 16ccbdb Compare April 28, 2026 16:04
@fglock fglock merged commit 6d622d7 into master Apr 28, 2026
2 checks passed
@fglock fglock deleted the fix/archive-zip-mp3tag branch April 28, 2026 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant