Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

SmokeTesters Complain of Missing Dependencies Which a Module's Makefile.PL Requires

by hesco (Deacon)
on Jun 06, 2008 at 17:00 UTC ( [id://690701]=perlquestion: print w/replies, xml ) Need Help??

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

I just got an email from a smoke tester reporting "Can't locate File/Util.pm in @INC". Details here:

Date: Fri, 6 Jun 2008 17:20:12 +0100 Subject: FAIL Test-MonitorSites-0.13 darwin-2level 7.9.0 From: "JJ" <jj@jonallen.info> To: cpan-testers@perl.org Cc: HESCO@cpan.org X-Reported-Via: Test::Reporter 1.4001, via CPAN::Reporter 1.15 <snip> ------------------------------ PROGRAM OUTPUT ------------------------------ Output from '/Users/jj/perl/perl-5.8.1/bin/perl Makefile.PL': Can't locate File/Util.pm in @INC (@INC contains: /Users/jj/perl/perl- +5.8.1/lib/5.8.1/darwin-2level /Users/jj/perl/perl-5.8.1/lib/5.8.1 /Us +ers/jj/perl/pe rl-5.8.1/lib/site_perl/5.8.1/darwin-2level /Users/jj/perl/perl-5.8.1/l +ib/site_perl/5.8.1 /Users/jj/perl/perl-5.8.1/lib/site_perl .) at Make +file.PL line 4 . BEGIN failed--compilation aborted at Makefile.PL line 4. ------------------------------ PREREQUISITES ------------------------------ Prerequisite modules loaded: No requirements found
however, the Makefile.PL for that module includes File::Util included in the PREREQ_PM hash, but also a use File::Util, plus some code which uses that module, prior to running the WriteMakefile() function to handle pre-requisites. It reads:

use strict; use warnings; use ExtUtils::MakeMaker; use File::Util; print "==> These tests generate email output + <==\n"; print "==> Where would you like your test results sent? + <==\n"; print "==> By default test email summaries go to dev-null\@example.co +m <==\n"; print "==> By default test sms summaries go to dev-null\@example.com + <==\n"; my $email = prompt('Send test email summaries to?','devnull@example.co +m'); my $sms = prompt('Send test sms summaries to?','devnull@example.com'); my($f) = File::Util->new(); my @config_files = $f->list_dir( 't/ini' , '--pattern=\.ini$' ); foreach my $config_file (@config_files){ print "writing t/$config_file \n"; open ('INI','>',"t/$config_file"); open ('SRC',"t/ini/$config_file"); while(<SRC>){ if(m/^sms_recipients =/){ $_ =~ s/$_/sms_recipients = '$sms'\n/; } if(m/^results_recipients =/){ $_ =~ s/$_/results_recipients = '$em +ail'\n/; } print INI $_; } close SRC; close INI; } WriteMakefile( NAME => 'Test::MonitorSites', AUTHOR => 'Hugh Esco <hesco@greens.org>', VERSION_FROM => 'lib/Test/MonitorSites.pm', ABSTRACT_FROM => 'lib/Test/MonitorSites.pm', PL_FILES => {}, PREREQ_PM => { 'Cwd' => 0, 'Carp' => 0, 'File::Util' => 0, 'Data::Dumper' => 0, 'Test::More' => 0, 'Test::Pod' => 1.14, 'Test::Pod::Coverage' => 1.04, 'Test::Builder' => 0, 'Mail::Mailer' => 0, 'Config::Simple' => 0, 'WWW::Mechanize' => 0, 'Test::WWW::Mechanize' => 0, 'Test::HTML::Tidy' => 0, 'HTTP::Request::Common' => 0, 'Test::Builder::Tester' => 0, }, dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', } +, clean => { FILES => 'Test-MonitorSites-* t/*.ini' }, );
I would assume that the failure is the result of my attempt to use and instantiate an object from File::Util, before I ran the WriteMakeFile() method over my list of PREREQ_PM's. Is there some way to switch things around and still have this all work? If I move the File::Util code below the WriteMakefile() invocation, would it benefit from PREREQ_PM installations? Would using a require later in the code, instead of a use at the top of the script make the difference here?

Does the cpan prompt have some way of uninstalling a module so I could test this on my local sandbox, without having to just guess at things and hope that this change does what I intend without breaking something else?

UPDATE:

My File::Util dependency is limited to this single invocation in Makefile.PL,

my($f) = File::Util->new(); my @config_files = $f->list_dir( 't/ini' , '--pattern=\.ini$' ); foreach my $config_file (@config_files){
which rewrites some configuration files so that the tests send sample output to the installers email and sms addresses. I'm about to commit version 0.15 of this module using Syphillis' idea. But I'm guessing its time to reach for TIMTOWTDI for this simple task.

-- Hugh

if( $lal && $lol ) { $life++; }

Replies are listed 'Best First'.
Re: SmokeTesters Complain of Missing Dependencies Which a Module's Makefile.PL Requires
by syphilis (Archbishop) on Jun 06, 2008 at 23:10 UTC
    I believe you'll avoid such FAIL reports if, in your Makefile.PL you replace:
    use File::Util;
    with
    eval {require File::Util;}; exit if $@;
    That way, if File::Util is not installed, the build process simply stops - and no FAIL is either recorded or sent. (You'd probably want to provide a message prior to the exit - so that the user knows why the process is stopping.)

    There might now exist a better solution, btw.

    Cheers,
    Rob
Re: SmokeTesters Complain of Missing Dependencies Which a Module's Makefile.PL Requires
by bingos (Vicar) on Jun 07, 2008 at 07:50 UTC

    No matter where you put your instantiation of the File::Util, prerequisites don't get installed until after Makefile.PL has finished being processed.

    You can follow the advice given above regarding exiting early if File::Util isn't found ( so avoiding a raft of FAILs from the CPAN Testers ).

    This situation is the reasoning behind configure_requires support, it may be worth following the progress on that.

Re: SmokeTesters Complain of Missing Dependencies Which a Module's Makefile.PL Requires
by Khen1950fx (Canon) on Jun 06, 2008 at 17:53 UTC
    I couldn't duplicate the error; however, tests 10, 12, and 14 failed. t/perlcritic.t only failed 1 of 256 tests. Otherwise, it installed ok. I had no problem with File::Util.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://690701]
Approved by moritz
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-23 18:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found