Perl-Toolchain-Gang / Module-Metadata

Gather package and POD information from perl module files
http://metacpan.org/release/Module-Metadata/
Other
8 stars 16 forks source link

Add $self->{inc} to @INC whilst evaluating version #26

Open rhalliday opened 7 years ago

rhalliday commented 7 years ago

WWW::Scripter defines multiple packages in the same file, some of those packages contain a block of text that Module::Metadata tries to evaluate to get a version. I've added t/lib/0_1/Bar.pm which contains the whole offending block but essentially the line that Module::Metadata tries to evaluate is "use WWW::Scripter; use WWW::Scripter; $VERSION = $WWW'Scripter'VERSION;"

When using Carton to install WWW::Scripter this causes Module::Metadata to error with "Can't find module". This is due all the modules being installed in a local/lib directory. If we add $self->{inc} to @INC before evaluating the version line then Perl looks in the right places for the WWW::Scripter module.

Leont commented 7 years ago

This doesn't sound like the right solution to me at all (Module::Metadata should use less globals not more), but it might be the only solution :-/

haarg commented 7 years ago

This has been discussed before, but I believe we decided it was a bad idea. The current code unfortunately adds 'lib' to @INC sometimes, but that can't be removed due to backwards compatibility.

PAUSE indexing works differently. It extracts a single version from each .pm file, and uses it for every package that if finds in the file.

rhalliday commented 7 years ago

Hmm, I couldn't think of a way to do it without modifying @INC in some way. Modifying the way that Module::Metadata specifies the versions of all the packages in one file has the potential to cause more issues than it fixes.

karenetheridge commented 7 years ago

There's a lot of 'wtf's in lib/WWW/Scripter.pm... without comments to explain the author's intent in some of the constructs, I would lean towards "we cannot support this". There is no reason to have a $VERSION declared in secondary packages in a file, as it's not possible to mix and match versions, and secondary packages should only be used internally (otherwise, they should be split out into separate files so they can be loaded separately).