Subject: | Main module not located when it's under a "gathered" directory. |
There is a problem with guessing/finding the main module when it
happens to be under a "gathered" directory. The most immediate
consequence is that the main abstract cannot be located. The following
setup shows how the problem appears (I unfortunately haven't been able
to figure out how to build a committable test for it):
$ ls -lR
.:
total 8
-rw-r--r-- 1 lucs lucs 100 2011-01-21 10:34 dist.ini
drwxr-xr-x 3 lucs lucs 4096 2011-01-21 10:27 src
./src:
total 4
drwxr-xr-x 2 lucs lucs 4096 2011-01-21 10:43 lib
./src/lib:
total 4
-rw-r--r-- 1 lucs lucs 25 2011-01-21 10:14 Foo.pm
$ cat dist.ini
name = Foo
version = 0.001
license = Perl_5
copyright_holder = A.U.Thor
[GatherDir]
root = src
$ cat src/lib/Foo.pm
#ABSTRACT: The abstract
$ dzil build
[DZ] beginning to build Foo
[DZ] guessing dist's main_module is lib/Foo.pm
[DZ] extracting distribution abstract from lib/Foo.pm
file 'lib/Foo.pm' does not exist at
/opt/apps/perl/lib/site_perl/5.12.2/Dist/Zilla/Util.pm line 54
The following patch fixes it, but it's not clear to me whether it
could have unintended side effects:
---
lib/Dist/Zilla.pm | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/Dist/Zilla.pm b/lib/Dist/Zilla.pm
index 8bc9b15..2dd0134 100644
--- a/lib/Dist/Zilla.pm
+++ b/lib/Dist/Zilla.pm
@@ -122,7 +122,7 @@ has abstract => (
die "no abstract given and no main_module found; make sure your
main module is in ./lib\n";
}
- my $filename = $self->main_module->name;
+ my $filename = $self->main_module->_original_name;
$self->log("extracting distribution abstract from $filename");
my $abstract = Dist::Zilla::Util->abstract_from_file($filename);
@@ -205,7 +205,7 @@ has main_module => (
push @errorlines,"Cannot continue without a main_module";
$self->log_fatal( join qq{\n}, @errorlines );
}
- $self->log("${guessing}dist's main_module is " . $file->name);
+ $self->log("${guessing}dist's main_module is " .
$file->_original_name);
return $file;
},
--
After applying the patch:
$ dzil build
[DZ] beginning to build Foo
[DZ] guessing dist's main_module is src/lib/Foo.pm
[DZ] extracting distribution abstract from src/lib/Foo.pm
[DZ] writing Foo in Foo-0.001
[DZ] writing archive to Foo-0.001.tar.gz
$ ls -lR Foo-0.001
Foo-0.001:
total 4
drwxr-xr-x 2 lucs lucs 4096 2011-01-21 10:45 lib
Foo-0.001/lib:
total 4
-rw-r--r-- 1 lucs lucs 25 2011-01-21 10:45 Foo.pm