Skip to content

Fix CPAN prereq version detection and add missing module stubs#374

Merged
fglock merged 3 commits into
masterfrom
fix/jcpan-version-detection
Mar 25, 2026
Merged

Fix CPAN prereq version detection and add missing module stubs#374
fglock merged 3 commits into
masterfrom
fix/jcpan-version-detection

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Mar 25, 2026

Summary

Fixes multiple CPAN module installation issues related to version detection and %INC paths.

Issue 1: jcpan -t DateTime failing with version 'undef'

Dist::CheckConflicts version 'undef' is not in required range '0.02'
CPAN::Meta::Check version 'undef' is not in required range '0.011'

Root Cause: get_version() in ExtUtils::MM_Unix.pm only matched $VERSION but not $Package::Name::VERSION.

Fix: Updated regex patterns from /\$VERSION/ to /\$[\w:]*VERSION/ to match both styles.

Issue 2: jcpan -t Specio failing with missing modules

Clone is not installed (any version required)
re is not installed (any version required)

Root Cause: These modules are built-in (Java implementations or XS-only), but the prereq check looks for .pm files with VERSION.

Fix: Added stub .pm files with VERSION declarations.

Issue 3: Test::Specio failing with "Could not open UNIVERSAL.pm"

Root Cause: Built-in Java modules set %INC{'Module.pm'} = "Module.pm" (no path), but Test::Specio tries to open $INC{...} entries.

Fix: Modified PerlModuleBase.initializeModule() to check if a .pm stub exists in the JAR and use jar:PERL5LIB/Module.pm format if so.

Changes

  1. ExtUtils/MM_Unix.pm: Fix VERSION detection regex for package-prefixed declarations
  2. PerlModuleBase.java: Use proper jar: paths in %INC when .pm stub exists
  3. re.pm: New stub for prereq detection (Java impl in Re.java)
  4. Clone.pm: New wrapper with Clone::PP fallback (XS-only module)
  5. UNIVERSAL.pm: New stub for %INC path resolution
  6. open.pm: Add VERSION
  7. B.pm: Fix VERSION format (non-numeric versions fail version->parse())

Test Plan

  • Unit tests pass (make)
  • MM->parse_version() returns correct versions
  • jcpan -t DateTime no longer reports version 'undef'
  • jcpan -t Specio no longer reports Clone/re as missing
  • Test::Specio no longer fails with "Could not open UNIVERSAL.pm"

Generated with Devin

fglock and others added 2 commits March 25, 2026 12:18
The get_version() helper in ExtUtils::MM_Unix only matched $VERSION but
not $Package::Name::VERSION. This caused modules like Dist::CheckConflicts
that use the full package name in their version declaration to report
version 'undef'.

Updated the regex patterns to use /\$[\w:]*VERSION/ to match both:
- $VERSION = '1.23'
- $Dist::CheckConflicts::VERSION = '0.11'

This fixes jcpan -t DateTime which was failing prerequisite checks due to
incorrect version detection for Dist::CheckConflicts and CPAN::Meta::Check.

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

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
- re.pm: Add stub with VERSION for the built-in re pragma (implemented
  in Re.java). Fixes "re is not installed" prereq check errors.

- Clone.pm: Add pure Perl fallback wrapper that loads Clone::PP when
  XSLoader fails. Clone is XS-only (no .pm files), so this provides
  a working Clone module for PerlOnJava.

- open.pm: Add VERSION to stub for prereq detection.

- B.pm: Fix VERSION to use numeric-only format (1.88) instead of
  1.00_perlonjava which failed version->parse() validation.

These changes fix `jcpan -t Specio` which was failing with:
- Clone is not installed
- re is not installed

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

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@fglock fglock changed the title Fix MM->parse_version() for package-prefixed VERSION declarations Fix CPAN prereq version detection and add missing module stubs Mar 25, 2026
When a built-in Java module (like UNIVERSAL, re, Clone) has a .pm stub file
in the bundled lib, set %INC to the jar:PERL5LIB path format instead of just
the module name. This allows code that opens %INC entries (like Test::Specio)
to find a real file.

Changes:
- PerlModuleBase.initializeModule(): Check if .pm stub exists in JAR, use
  jar:PERL5LIB/Module.pm format if so
- UNIVERSAL.pm: New stub file with VERSION for prereq detection

This fixes Test::Specio tests that were failing with:
  "Could not open UNIVERSAL.pm for the test"

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

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@fglock fglock merged commit 4e68ad0 into master Mar 25, 2026
2 checks passed
@fglock fglock deleted the fix/jcpan-version-detection branch March 25, 2026 11:57
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