develooper Front page | perl.perl5.porters | Postings from September 2012

Re: Changing the Perl error message when a module is not found

Thread Previous | Thread Next
From:
Dominic Hargreaves
Date:
September 16, 2012 12:16
Subject:
Re: Changing the Perl error message when a module is not found
Message ID:
20120916191631.GO4116@urchin.earth.li
On Sun, Sep 16, 2012 at 09:07:33PM +0200, Michael Stapelberg wrote:
> I’ve been dealing with people who have little to no experience with
> Perl over several years. A very common problem for people who are new to
> Perl is to figure out why a Perl script does not work when it spits
> something in their face along the lines of
> 
>     Can't locate LWP/UserAgent.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.12.4 /usr/local/share/perl/5.12.4 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.12 /usr/share/perl/5.12 /usr/local/lib/site_perl .) at -e line 1. 
>     BEGIN failed--compilation aborted at -e line 1.
> 
> Therefore, as a first step to help people with it, I’ve created
> http://michael.stapelberg.de/cpan/ where I can point people to when they
> encounter this problem and ask for help.
> 
> However, it’d be much better to make Perl itself say something more
> helpful in that situation (many people don’t even ask for support and
> just give up).
> 
> Therefore, what do you think about changing the Perl error message when
> modules are not found to something like this?
> 
>     ERROR: Could not load Perl module LWP::UserAgent
> 
>     I looked for LWP/UserAgent.pm in these paths (@INC):
>     /etc/perl /usr/local/lib/perl/5.12.4 /usr/local/share/perl/5.12.4
>     /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.12 /usr/share/perl/5.12
>     /usr/local/lib/site_perl
> 
>     Try installing LWP::UserAgent, for example with cpan -i
>     LWP::UserAgent
> 
> Key is that the last message (which people look at first) is helpful and
> the right solution for this problem. Also, the rest of the error message
> talks about LWP::UserAgent (not LWP/UserAgent.pm) and clearly explains
> that this is a Perl module (giving the user a keyword to search for and
> a better understanding of the problem).

I would much rather see this be a brief reference to a piece of perldoc
which can be updated with whatever the best current advice is. (I also
don't particularly like the use of the personal pronoun):

Can't locate LWP/UserAgent.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.12.4 /usr/local/share/perl/5.12.4 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.12 /usr/share/perl/5.12 /usr/local/lib/site_perl .); please see 'perldoc perlmodinst or visit http://perldoc.perl.org/... for more details' at -e line 1.

As far as the actual advice (in the hypothetical perldoc, or your web
site, I think it would be good to mention some of the distro specific ways
of installing perl modules (for example, search for the .pm in
<http://www.debian.org/distrib/packages> and run apt-get install [...]
on a Debian system, and equivalents for other systems). Often, especially
for novice users, the packaged versions are much easier to install and
maintain than CPAN.pm style installs.

-- 
Dominic Hargreaves | http://www.larted.org.uk/~dom/
PGP key 5178E2A5 from the.earth.li (keyserver,web,email)

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About