in reply to Re^4: diagnostics: warning, deprecation, error
in thread diagnostics: warning, deprecation, error

This is much nicer, and I guess I've always just accepted the way it is now for historic reasons, it looked liked this since I first experienced it, and I knew what it meant and what to do. I'm putting together a patch that makes it look like your suggestion:

./perl -MDerp::Derp Can't locate Derp/Derp.pm in @INC See: perldoc -v @INC You may need to install the Derp::Derp module: https://metacpan.org/search?q=Derp::Derp @INC entries checked: /home/marto/localperl/lib/site_perl/5.42.0/x86_64-linux /home/marto/localperl/lib/site_perl/5.42.0 /home/marto/localperl/lib/5.42.0/x86_64-linux /home/marto/localperl/lib/5.42.0. BEGIN failed--compilation aborted. ~/localperl/bin

But need to fix the breaking tests that go looking for the old format in:

Failed 5 tests out of 2667, 99.81% okay. ../cpan/Test-Simple/t/Legacy/fail-more.t ../cpan/parent/t/parent.t op/inccode-tie.t op/inccode.t op/require_errors.t

Replies are listed 'Best First'.
Re^6: diagnostics: warning, deprecation, error
by Anonymous Monk on Feb 20, 2026 at 20:59 UTC
    I've been rethinking this as someone who spends a lot of time with perl at the command line. I think the reason for suggesting a cleanup on the missing module error is that there's a lot of information and it's a mess. I noticed that everything inside parenthesis looks as if it was hastily added at some point and isn't really necessary. It might be nicer to have perl puke less text upon this error than more:
    Can't locate Super/Duper.pm in @INC
    BEGIN failed--compilation aborted.
    

      As someone who help people with their Can't locate problems numerous times, the inclusion of @INC has been useful virtually every time. It helps identify which Perl is used, it helps identify if local::lib, PERL5LIB or something else is being used or not, and it helps identify what path was added using PERL5LIB (which is often different than what the user claims was added). These are key in debugging such problems.

        Oh, and @INC at the time of the error is commonly different than the @INC shown by perl -V.

      Making the error more consistent with the formatting seen in perl -V was one of the things I really liked about your initial idea. I agree with ikegami, removing the INC part would make it more difficult to help people having problems, and elevates problems when multiple perls are in play.

Re^6: diagnostics: warning, deprecation, error
by ikegami (Patriarch) on Feb 17, 2026 at 15:22 UTC

    You two removed the crucial file and line number.

      This is not the case. On an unmodified perl running perl -MDerp::Derp outputs:

      perl -MDerp::Derp Can't locate Derp/Derp.pm in @INC (you may need to install the Derp::D +erp module) (@INC entries checked: /usr/lib/perl5/5.42/site_perl /usr +/share/perl5/site_perl /usr/lib/perl5/5.42/vendor_perl /usr/share/per +l5/vendor_perl /usr/lib/perl5/5.42/core_perl /usr/share/perl5/core_pe +rl). BEGIN failed--compilation aborted.

      Calling the same way from the patched perl produces the output shown here. From within a script we get the expected result:

      cat test.pl use Derp::Derp; ~/localperl/bin ./perl test.pl Can't locate Derp/Derp.pm in @INC See: perldoc -v @INC You may need to install the Derp::Derp module: https://metacpan.org/search?q=Derp::Derp @INC entries checked: /home/marto/localperl/lib/site_perl/5.42.0/x86_64-linux /home/marto/localperl/lib/site_perl/5.42.0 /home/marto/localperl/lib/5.42.0/x86_64-linux /home/marto/localperl/lib/5.42.0 at test.pl line 1. BEGIN failed--compilation aborted at test.pl line 1. ~/localperl/bin
      Did they actually remove the file name and line number, or does that just not show up when using -M , even in the existing error message

      Because my experiments say the latter.

      C:\Users\pryrt>echo use Super::Duper; >> tmp.pl C:\Users\pryrt>perl tmp.pl Can't locate Super/Duper.pm in @INC (you may need to install the Super +::Duper module) (@INC entries checked: c:/usr/local/apps/strawberry/p +erl/site/lib/MSWin32-x64-multi-thread c:/usr/local/apps/strawberry/pe +rl/site/lib c:/usr/local/apps/strawberry/perl/vendor/lib c:/usr/local +/apps/strawberry/perl/lib) at tmp.pl line 1. BEGIN failed--compilation aborted at tmp.pl line 1. C:\Users\pryrt>perl use Super::Duper; Can't locate Super/Duper.pm in @INC (you may need to install the Super +::Duper module) (@INC entries checked: c:/usr/local/apps/strawberry/p +erl/site/lib/MSWin32-x64-multi-thread c:/usr/local/apps/strawberry/pe +rl/site/lib c:/usr/local/apps/strawberry/perl/vendor/lib c:/usr/local +/apps/strawberry/perl/lib) at - line 1. BEGIN failed--compilation aborted at - line 1. C:\Users\pryrt>perl -MSuper::Duper -e 1 Can't locate Super/Duper.pm in @INC (you may need to install the Super +::Duper module) (@INC entries checked: c:/usr/local/apps/strawberry/p +erl/site/lib/MSWin32-x64-multi-thread c:/usr/local/apps/strawberry/pe +rl/site/lib c:/usr/local/apps/strawberry/perl/vendor/lib c:/usr/local +/apps/strawberry/perl/lib). BEGIN failed--compilation aborted.

      I obviously cannot test whether marto's unpublished fix behaves the same way.

      But just because the example shows a situation in which the line number and file name aren't shown (because they are meaningless) doesn't mean that the solution proposed will actually get rid of that information when it's available.


      edit: I see that between the time I started my post and when I actually posted, the AM posted essentially the same information, with confirmation that their suggestion does not get rid of that information.
      > You two removed the crucial file and line number.

      We did not. My example uses a bogus module on the -M switch to trigger Perl and when done like that she does not return file and line number not even good old at -e line 1. For that you need to run perl from a file:

      perl -MIPC::Cmd=run -Mautodie -le '$n="/tmp/blorp.pl";open$f,">",$n;pr +int$f "use Blorp;";close$f;@_=run(command=>"perl $n");$_=join"",@{$_[ +2]};s/ ([\(])/\n/g;s/ ([\/])/\n $1/g;s/\)//g;chomp;print'
      Can't locate Blorp.pm in @INC
      you may need to install the Blorp module
      @INC entries checked:
       /Users/u/perl5/perlbrew/perls/perl-5.42.0/lib/site_perl/5.42.0/darwin-2level
       /Users/u/perl5/perlbrew/perls/perl-5.42.0/lib/site_perl/5.42.0
       /Users/u/perl5/perlbrew/perls/perl-5.42.0/lib/5.42.0/darwin-2level
       /Users/u/perl5/perlbrew/perls/perl-5.42.0/lib/5.42.0 at
       /tmp/blorp.pl line 1.
      BEGIN failed--compilation aborted at
       /tmp/blorp.pl line 1.