Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rhalliday
Copy link

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.

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. 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". 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
Copy link
Member

Leont commented Nov 3, 2016

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
Copy link
Member

haarg commented Nov 3, 2016

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
Copy link
Author

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
Copy link
Member

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).

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.

4 participants