develooper Front page | perl.perl6.language | Postings from February 2001

Re: Auto-install (was autoloaded...)

Thread Previous | Thread Next
Michael G Schwern
February 8, 2001 05:32
Re: Auto-install (was autoloaded...)
Message ID:
On Thu, Feb 08, 2001 at 08:53:07AM -0000, Filipe Brandenburger wrote:
> Branden wrote:
> >When I download a module from Internet, say module Foo, then I install
> >it and try to use it, it promptly breaks when it tries to `use Bar'
> >and sees that Bar is not installed on my system. So I have to go on
> >to Internet again, find Bar, install it, so on, until I find Bar needs
> >Baz, or anything
> >like it.
> >
> >Well, I think this could be handled by Perl itself.

Oddly enough, Perl does handle this... mostly.  The CPAN shell can
automatically download and install prerequisites for modules, provided
the module explicitly declares the prereqs.  Class::DBI ultimately
needs something like 9 other CPAN modules, which would be a nightmare
but for this feature.

        perl -MCPAN -e 'install Class::DBI'

Its only on the more recent versions of the CPAN shell (>1.48), but
since the shell whines about updating itself everytime you use it,
there's no reason not to have the latest.

I've taken advantage of this for local projects using the CPAN::Site
module and setting up a local repository for local code.

Now, the idea of perl automagically going out and downloading
untrusted code (all the code on CPAN is untrusted) from untrusted
sources (ergo, CPAN is untrusted) from untrusted scripts (if its a
core feature, any script can do it) makes my feet itch.  We can't do
this until there's a way to security audit CPAN... which is supposed
to be my job. :(

However, if you *really* want to do it, you can pretty easily.  Just
code up a function which tries to use the given module, otherwise it
fires up the CPAN shell and install it, then tries to use it again.
I've been meaning to do this for a while now.

Another problem is the fact that not everything on CPAN installs
easily.  Most does, but some require certain interaction and
configuration (LWP, Net::FTP, most any DBD driver...).  Those can't be
done automagically, but if we could do 80% then that's ok.


Michael G. Schwern   <>
If you have to shoot, shoot!  Don't talk.
		-- Tuco, "The Good, The Bad And The Ugly"

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About