Skip Menu |

This queue is for tickets about the Dist-Zilla-Plugin-Test-NewVersion CPAN distribution.

Report information
The Basics
Id: 87562
Status: resolved
Priority: 0/
Queue: Dist-Zilla-Plugin-Test-NewVersion

People
Owner: ether [...] cpan.org
Requestors: TEAM [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.002
Fixed in: 0.004



Subject: "Virtual" (InMemory or FromCode) files cannot be read by Module::MetaData
Hi there, It's possible I'm doing something wrong here, but this seems like a bug: Calling ->new_from_file expects that the parameter will be a regular file on disk that can be opened and read: Module::Metadata->new_from_file($_->name)->name (https://metacpan.org/source/ETHER/Dist-Zilla-Plugin-Test-NewVersion-0.002/lib/Dist/Zilla/Plugin/Test/NewVersion.pm#L57) However, other plugins may have added files which aren't ::OnDisk, for example ::InMemory or ::FromCode. That method is doing so a few lines further down, for example, and http://dzil.org/tutorial/writing-plugins.html makes me think that's legitimate expected behaviour at the gather_files stage. So: should @files perhaps be filtered to check for -r or maybe even ->isa('Dist::Zilla::File::OnDisk'), so that those 'virtual' files can be ignored? The specific failure case I'm seeing is with this: [PodInherit] [Test::NewVersion] resulting in the following error: [PodInherit] Generated 16 POD files Can't call method "name" on an undefined value at .../site_perl/5.16.3/Dist/Zilla/Plugin/Test/NewVersion.pm line 56, <DATA> line 23. (->name is called twice on that line, but the undefined value is the Module::Metadata->new_from_file return value, rather than $_) however it works if you put them the other way around: [Test::NewVersion] [PodInherit] cheers, Tom
Subject: Re: [rt.cpan.org #87562] "Virtual" (InMemory or FromCode) files cannot be read by Module::MetaData
Date: Sat, 3 Aug 2013 10:31:17 -0700
To: Thomas Edward Alexander Molesworth via RT <bug-Dist-Zilla-Plugin-Test-NewVersion [...] rt.cpan.org>
From: Karen Etheridge <ether [...] cpan.org>
On Fri, Aug 02, 2013 at 10:16:25PM -0400, Thomas Edward Alexander Molesworth via RT wrote: Show quoted text
> Calling ->new_from_file expects that the parameter will be a regular file on disk that can be opened and read: > Module::Metadata->new_from_file($_->name)->name > However, other plugins may have added files which aren't ::OnDisk, for example ::InMemory or ::FromCode. That method is doing so a few lines further down, for example, and http://dzil.org/tutorial/writing-plugins.html makes me think that's legitimate expected behaviour at the gather_files stage. > > So: should @files perhaps be filtered to check for -r or maybe even ->isa('Dist::Zilla::File::OnDisk'), so that those 'virtual' files can be ignored?
Yes it should. Looking more closely at Dist::Zilla::Dist::Builder::build_in, files aren't actually "finalized" (written out to disk) until after the FileGatherer, FilePruner and FileMunger phases have all run -- so when this plugin does its thing, the file might not actually exist on disk yet. So it needs to deal with the different ways this file could exist. Show quoted text
> ...however it works if you put them the other way around: > [Test::NewVersion] > [PodInherit]
This is because both the plugins are FileGatherers, and the file PodInherit adds hasn't been added yet by the time Test::NewVersion does its thing. This highlights another bug -- we shouldn't be finalizing the list of files to check until later on (after all files have been added) -- it should be delayed until the FileMunger phase. This is all very fixable, but may take a few days as I'm about to leave on a business trip - but stay tuned, and thanks for the report!
0.003 has just been uploaded with fixes that properly handle files being added from other plugins. I'll fix the issue relating to plugin ordering (with filenames being fetched at the wrong phase) in a subsequent release (hopefully still this weekend).
That's great - my failing case is now working fine with 0.003. Thanks for the quick response! Tom
Subject: Re: [rt.cpan.org #87562] "Virtual" (InMemory or FromCode) files cannot be read by Module::MetaData
Date: Sat, 3 Aug 2013 18:28:44 -0700
To: Thomas Edward Alexander Molesworth via RT <bug-Dist-Zilla-Plugin-Test-NewVersion [...] rt.cpan.org>
From: Karen Etheridge <ether [...] cpan.org>
On Sat, Aug 03, 2013 at 04:01:09PM -0400, Thomas Edward Alexander Molesworth via RT wrote: Show quoted text
> That's great - my failing case is now working fine with 0.003. Thanks for the quick response!
0.004 is now uploaded, which fixes the plugin ordering issue.