Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Detecting failures easily/obviously with cpanm

by hippo (Bishop)
on Jun 16, 2022 at 13:54 UTC ( [id://11144802]=perlquestion: print w/replies, xml ) Need Help??

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

How do you detect installation failures when using cpanm to install a large number of modules?

I have just attempted to install about 40 modules in one go and the end of the cpanm output (the last screenful) lists no errors. All it says is 38 distributions installed. However, several of the modules earlier in the list have failed. I only noticed this because I was watching the output while it worked. The exact number that it reported doesn't seem that useful as it appears to include dependencies and not to include modules already installed (and therefore no-ops).

Ideally I'd like a summary at the end of the output which lists all the failures or prints "All installations succeeded" or else have the output in colour so that failures are instantly detectable. Is either of these an option, perhaps with some additional module? I could not immediately find such a thing.

Or am I just misusing cpanm and there is some better way to install swathes of modules?


🦛

Replies are listed 'Best First'.
Re: Detecting failures easily/obviously with cpanm
by stevieb (Canon) on Jun 16, 2022 at 16:12 UTC

    cpanm -q Module::Name can help. The -q (aka --quiet) flag reduces the output to list only the distribution installs attempted, and their success or fail status.

    Typically what I do though is just re-run the cpanm command again, as it'll skip over all the successful dists, and focus squarely on the failed ones making them easy to identify.

      I had considered the option of just re-running the whole lot to make the failures stand out, however that does make my inefficiency-spidey-sense start tingling. One of the modules in today's bundle was Mail::Spamassassin for instance and that takes several minutes to run its test suite. Still worth bearing in mind, though.

      Thanks for the pointer to -q - I will definitely give that one a go.


      🦛

Re: Detecting failures easily/obviously with cpanm
by 1nickt (Canon) on Jun 17, 2022 at 11:16 UTC

    Hi hippo,

    For large numbers of modules I usually make use of cpanm's --installdeps switch, which requires building a list of modules you wish to install and saving to a simple formatted file typically named cpanfile. The output from this command (which I run with --quiet as already suggested by stevieb) includes failures at the end something like:

    ! Installing the dependencies failed: Module 'NOTstrictures' is not in +stalled ! Bailing out the installation for .

    Hope this helps!


    The way forward always starts with a minimal test.

      This sounds very promising, 1nickt - thank you. It might just be the best compromise and I will definitely give it a try.

      Update: Some three weeks on and I have now used this method several times for installing long lists of dependencies for applications. It does exactly what I want - thanks very much for the pointer.


      🦛

Re: Detecting failures easily/obviously with cpanm
by Anonymous Monk on Jun 16, 2022 at 20:51 UTC

    Is using the cpan client an option? It comes with Perl, and if you install a bunch of modules it lists the failures (if any) at the end.

      It is always an option, yes. I have mostly found that cpanm fits my needs more but this is the sort of very useful feature which would make me look again at old cpan. Thanks for bringing this up.


      🦛

Re: Detecting failures easily/obviously with cpanm -- CPAN::Shell
by Discipulus (Canon) on Jun 17, 2022 at 11:42 UTC
    Hello hippo,

    why use a perl tool when you can just use perl? :)

    perl -MCPAN -e "CPAN::Shell->install(q(Acme::Meta));" >> acme-meta.log

    You can expand this with logging ability, nice error print on screen.. at your wish

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (6)
As of 2024-03-28 09:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found