ownlifeful has asked for the wisdom of the Perl Monks concerning the following question:

Greetings, dear PerlMonks,

I have released a module to CPAN, but now I am having trouble installing the latest version. The module is called: Graph::Undirected::Hamiltonicity

A demo is hosted at https://ownlifeful.com/, and the source code is hosted on GitHub.

To install the module from the source, you would follow these steps:

  1. Get the source: git clone https://github.com/ownlifeful/Graph-Undirected-Hamiltonicity.git
  2. cd Graph-Undirected-Hamiltonicity
  3. perl ./Build.PL
  4. ./Build

I see an error message as below:

... Configuring Graph-Undirected-Hamiltonicity-0.013 ... OK Building and testing Graph-Undirected-Hamiltonicity-0.013 ... FAIL ! Installing . failed. See /home/ashwin/.cpanm/work/1640803042.747791/ +build.log for details. Retry with --force to force install it. [DZ] error running {{["cpanm", "."]}} [DZ] install failed, left failed dist in place at .build/ZWeABKzuKx [DZ] error running {{["cpanm", "."]}} at inline delegation in Dist::Zi +lla for logger->log_fatal (attribute declared in /home/ashwin/perl5/p +erlbrew/perls/perl-5.34.0/lib/site_perl/5.34.0/Dist/Zilla.pm at line +782) line 18.

You can peek at the Build file. It shows:

#!/bin/sh /home/ashwin/perl5/perlbrew/perls/perl-5.34.0/bin/dzil authordeps | /h +ome/ashwin/perl5/perlbrew/perls/perl-5.34.0/bin/cpanm /home/ashwin/perl5/perlbrew/perls/perl-5.34.0/bin/dzil listdeps | /hom +e/ashwin/perl5/perlbrew/perls/perl-5.34.0/bin/cpanm /home/ashwin/perl5/perlbrew/perls/perl-5.34.0/bin/dzil install

The error occurs on the last line of the Build file. i.e., /home/ashwin/perl5/perlbrew/perls/perl-5.34.0/bin/dzil install and it looks like this:

Configuring Graph-Undirected-Hamiltonicity-0.013 ... OK Building and testing Graph-Undirected-Hamiltonicity-0.013 ... FAIL ! Installing . failed. See /home/ashwin/.cpanm/work/1640803042.747791/ +build.log for details. Retry with --force to force install it. [DZ] error running {{["cpanm", "."]}} [DZ] install failed, left failed dist in place at .build/ZWeABKzuKx [DZ] error running {{["cpanm", "."]}} at inline delegation in Dist::Zi +lla for logger->log_fatal (attribute declared in /home/ashwin/perl5/p +erlbrew/perls/perl-5.34.0/lib/site_perl/5.34.0/Dist/Zilla.pm at line +782) line 18.

I have looked at the build.log file as indicated above, and found nothing useful. So I tried running this command: strace cpanm . to track down where in the code the error occurs.

Here is an excerpt from strace:

... write(1, "OK\nBuilding and testing . ... ", 30) = 30 rt_sigprocmask(SIG_SETMASK, ~[RTMIN RT_1], [], 8) = 0 clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID| +SIGCHLD, child_tidptr=0x7f4de58514d0) = 720013 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 rt_sigprocmask(SIG_BLOCK, [ALRM], [], 8) = 0 rt_sigaction(SIGALRM, {sa_handler=0x562e53110bf0, sa_mask=[], sa_flags +=SA_RESTORER, sa_restorer=0x7f4de5bb0140}, {sa_handler=SIG_DFL, sa_ma +sk=[], sa_flags=SA_RESTORER, sa_restorer=0x7f4de5bb0140}, 8) = 0 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 alarm(3600) = 0 wait4(720013, [{WIFEXITED(s) && WEXITSTATUS(s) == 1}], 0, NULL) = 7200 +13 --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=720013, si_u +id=1000, si_status=1, si_utime=0, si_stime=0} --- alarm(0) = 3564 rt_sigprocmask(SIG_BLOCK, [ALRM], [], 8) = 0 rt_sigaction(SIGALRM, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RES +TORER, sa_restorer=0x7f4de5bb0140}, {sa_handler=0x562e53110bf0, sa_ma +sk=[], sa_flags=SA_RESTORER, sa_restorer=0x7f4de5bb0140}, 8) = 0 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0 ioctl(1, TCGETS, 0x7ffd19c2e700) = -1 ENOTTY (Inappropriate ioc +tl for device) fstat(1, {st_mode=S_IFREG|0644, st_size=127, ...}) = 0 write(2, "! Installing . failed. See /home"..., 133! Installing . fail +ed. See /home/ashwin/.cpanm/work/1640779718.720003/build.log for deta +ils. Retry with --force to force install it. ...

In the first line of the above excerpt, the error has yet to happen. In the last line of the same excerpt, the error has already happened.

I would appreciate a fresh set of eyes looking at this code. I can barely read the strace output. Can someone tell me what's going wrong?

I have used Dist::Zilla and perlbrew to develop and test this module.

Where's the bug? Is Dist::Zilla worth it? Should I switch to the MakeMaker approach?

Thanks a bunch, folks!

Replies are listed 'Best First'.
Re: Releasing a CPAN module using Dist::Zilla & perlbrew
by bliako (Abbot) on Dec 30, 2021 at 11:44 UTC

    I have tried to install it to my computer. It fails with:

    [DZ] attempt to add META.yml multiple times; added by: filename set by + GatherDir (Dist::Zilla::Plugin::GatherDir line 235); encoded_content + added by @Basic/GatherDir (Dist::Zilla::Plugin::GatherDir line 236); + text from coderef added by @Basic/MetaYAML (Dist::Zilla::Plugin::Met +aYAML line 78) [DZ] attempt to add LICENSE multiple times; added by: filename set by +GatherDir (Dist::Zilla::Plugin::GatherDir line 235); encoded_content +added by @Basic/GatherDir (Dist::Zilla::Plugin::GatherDir line 236); +content added by @Basic/License (Dist::Zilla::Plugin::License line 45 +) [DZ] attempt to add README multiple times; added by: filename set by G +atherDir (Dist::Zilla::Plugin::GatherDir line 235); encoded_content a +dded by @Basic/GatherDir (Dist::Zilla::Plugin::GatherDir line 236); c +ontent added by @Basic/Readme (Dist::Zilla::Plugaborting; duplicate f +iles would be produced at /usr/local/share/perl5/5.32/Dist/Zilla/App/ +Command/install.pm line 55. in::Readme line 52); content set by Readme (Dist::Zilla::Plugin::Readm +e line 69) [DZ] attempt to add Makefile.PL multiple times; added by: filename set + by GatherDir (Dist::Zilla::Plugin::GatherDir line 235); encoded_cont +ent added by @Basic/GatherDir (Dist::Zilla::Plugin::GatherDir line 23 +6); content set by MakeMaker (Dist::Zilla::Plugin::MakeMaker line 337 +); content added by @Basic/MakeMaker (Dist::Zilla::Plugin::MakeMaker +line 152) [DZ] attempt to add MANIFEST multiple times; added by: filename set by + GatherDir (Dist::Zilla::Plugin::GatherDir line 235); encoded_content + added by @Basic/GatherDir (Dist::Zilla::Plugin::GatherDir line 236); + bytes from coderef added by @Basic/Manifest (Dist::Zilla::Plugin::Ma +nifest line 63) -> FAIL Installing . failed. See xxx/.cpanm/work/1640862473.22542/buil +d.log for details. Retry with --force to force install it.

    Could the multiple times; be the culprit?

    Anyway, if you want to switch to ExtUtils::MakeMaker, then here is a basic Makefile.PL:

    use 5.006; use strict; use warnings; use ExtUtils::MakeMaker; WriteMakefile( #EDIT: only for testing #INSTALL_BASE => 'xxx', NAME => 'Graph::Undirected::Hamiltonicity', AUTHOR => q{XXX <XXX@cpan.org>}, VERSION_FROM => 'lib/Graph/Undirected/Hamiltonicity.pm', ABSTRACT_FROM => 'lib/Graph/Undirected/Hamiltonicity.pod', LICENSE => 'artistic_2', PL_FILES => {}, MIN_PERL_VERSION => '5.006', CONFIGURE_REQUIRES => { 'ExtUtils::MakeMaker' => '0', }, BUILD_REQUIRES => { 'Test::More' => '0', }, PREREQ_PM => { # add here dependencies #'ABC' => '1.6', #'Foo::Bar::Module' => '5.0401', }, # it adds your scripts too in bin/ EXE_FILES => [ glob("bin/*.pl") ], dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, clean => { FILES => 'Graph-Undirected-Hamiltonicity-*.gz' }, );

    In order to make a tarball for export to CPAN, then do: perl Makefile.PL && make && make manifest && make test && make dist

    Warning: I am seriously cargo-culting with the above so there can well be a better/safer way.

    bw, bliako

      I've received substantial help at irc.perl.org in the #distzilla channel. Not gonna lie, I treat dzil shamefully as a fat kid treats his 500 snicker bar strong candy stash. It really makes distributing to CPAN a breeze, but I always feel disgusted with myself after doing anything that is not "textbook". Then there's the "be like whomever author specific" minting bundles shitting up CPAN. Don't get me started. Need to go shower now. lol

        hehehe (and i am dzil-neutral).

Re: Releasing a CPAN module using Dist::Zilla & perlbrew
by NERDVANA (Priest) on Dec 30, 2021 at 22:12 UTC
    For what it's worth, the Build.PL also threw me for a loop, thinking at first that you were calling dzil as part of the module installation phase. Maybe a script to generate a script to help you run dzil is overkill? I think you should just use whatever cpanm and dzil are found in the path.

    I have never actually used dzil install. I always run dzil build and then run cpanm manually on the .tar.gz afterward. Does that work in your case?

Re: Releasing a CPAN module using Dist::Zilla & perlbrew
by perlfan (Parson) on Dec 29, 2021 at 21:51 UTC
    I think you're doing it wrong, dzil build creates the "distribution" directory you then cd into the created directory. That's where you run perl ./Makefile.PL that's generated (which I do sometimes for testing outside of dzil test). If you're coming along with your own Build.PL or Makefile.PL you're going to need to do hoop jumping, but it's possible to use these. Best bet is to start with a new module for practice, then slowly port your existing module over to use Dist::Zilla. update: your install instructions in the GH repo use dzil to install the module - no this is not the correct way to use this tool. It's meant as a developer only tool and never a prereq for actually installing the module. This would be insane, Dist::Zilla is a huge honkin' mess and if that's required to actually use your module, you're not gonna have anyone using it at all. correction: sorry misread, but seems like you're doing something that's out of order. Sometimes I forget I am in the distro directory that's been created by dzil and I get all kinds of weird errors. Make sure you're in the right directory and using the tool as intended.
Re: Releasing a CPAN module using Dist::Zilla & perlbrew (search the error message)
by Anonymous Monk on Dec 29, 2021 at 20:30 UTC
    Which version of Dist::Zilla? Upgrade Dist::Zilla, thats the anseer if you search for the error message

      It was at Dist-Zilla-6.024 which, as of this post, is the latest.

      Reinstalled cpanm --reinstall Dist::Zilla

      The outcome hasn't changed. Appreciate your help.

Re: Releasing a CPAN module using Dist::Zilla & perlbrew
by ownlifeful (Beadle) on Jan 23, 2022 at 10:53 UTC
    I cut out Dist::Zilla and switched to ExtUtils::MakeMaker. This has fixed the problem for me. Thanks a lot, folks.