I was wondering if anyone has heard anything regaurding this? I think it wouldnt be a bad idea to have a setting that would go on the shebang line that allowed CPAN to automaticaly install modules if they are missing on the system. Obviously some security concernes should be there. It would make the scripts a bit more portable.

Replies are listed 'Best First'.
Re: Perl 6 Module manager
by brian_d_foy (Abbot) on Apr 19, 2006 at 17:40 UTC

    It's much easier to put your script in a distribution and list its prerequisites in the usual way. When the user wants to install it, the prereqs get installed automatically.

    In the Makefile.PL, you end up with something like:

    # ... set some values WriteMakefile( 'NAME' => $script_name, 'VERSION' => $version, 'EXE_FILES' => [ $script_name ], 'PREREQ_PM' => { 'Test::More' => '0', #... et cetera }, 'MAN1PODS' => { $script_name => "\$(INST_MAN1DIR)/$script_name.1", }, );
    --
    brian d foy <brian@stonehenge.com>
    Subscribe to The Perl Review
Re: Perl 6 Module manager
by duff (Parson) on Apr 19, 2006 at 11:59 UTC

    Sounds like you want CPAN::AutoINC.

    Such behavior can't have such wide-spread appeal that it would make it as a switch in the perl interpreter. (I know I'm against it anyway :) However, there's nothing stopping someone from setting up their particular installation to do something like this.

    As for making scripts "more portable", I don't think so. What happens when someone uses this feature on a Windows system and perl automatically downloads and attempts to install a module that's Unix-specific? Or a module that requires a C compiler?

      I think the OP means "portable" in the sense "portable between otherwise equivalent machines with different sets of modules installed." That's a significant win; at a workplace, there will be dozens of desktop machines, and if you're writing scripts for other people to run, you have to be sure to only use modules that are available everywhere (or preinstall the ones you need everywhere.) But the base OS is still the same. I'm not going to worry about whether that fits a purist definition of "portable".

      I wouldn't use the suggested mechanism because of the security concerns. But I might if the security concern wasn't there -- and as I read this thread, it struck me that it's fairly easy to remove: when requesting a module, request it using an exact version and a cryptographic digest. I'd probably want the digests to be listed in a separate file, both to avoid messing up the main script and to allow for dependencies. For any missing module, you'd download the requested version and check its digest before installing it. I know that CPAN can already check signatures, but that still relies on an external source for the signatures to check against. And I also like the notion that you could depend on getting the exact versions of things that you originally wrote your script against, so you don't need to worry about some module changing its interface out from under you.

      It doesn't deal with the problem where a different version is already installed on the system, but it doesn't make that problem any worse either. It would just use whatever's there if some version existed, and you have no more than the usual version compatibility problems. It could even warn in such cases, which is better than what we get now.

      Or think of it this way: you could bundle up a script with the complete source for all modules it uses, and it unpacks and installs them all when it first runs if they aren't already on the system. The proposed idea does exactly that, except it uses unfakable pointers to each module rather than the actual data comprising the module.

Re: Perl 6 Module manager
by zentara (Cardinal) on Apr 19, 2006 at 11:45 UTC
    I don't like anything that is done "automatically". It is a security hole, and it "dumbs down" the user base, eventually making them totally dependent on the automated feature. It's a Microsoft strategy....keep users dumb and dependent. I mean it is not that hard to get something from cpan, and install it from source. What we need are more bundles! :-)

    I'm not really a human, but I play one on earth. flash japh
      It's a Microsoft strategy....keep users dumb and dependent.

      Don't take any more of Boeing's excuses and sloppy workmanship. For too long they've fobbed us of with expensive, bloated aircraft with 6 million parts. Assured us of their commitment to our safety; their rigorous test procedures; their quality; and still their aircraft fall out of the sky with unerring regularity.

      Don't take it any more. Assemble your own Douglas Dacota DC-3. Tried and trusted. Proven over and over. With our kit you can inspect all the parts yourself. Check every tolorance. Double check every sub assembly. Assemble it yourself, at home. Be sure that every part in the aircraft you fly is right.

      Don't take their excuses any more. Do it right. Do it yourself. Fly OSA.

      Coming soon. The OS Neurosurgery kit.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        I don't quite see the analogy between airplanes and Operating Systems, but I can tell you that if the MS-airplane crashed as often as it's OS, I would rather ride on the Open Source airplane.

        I can just hear the blackbox recording.... "captain, you need to reboot and hold F8...... I did, I did......oops was that F5?.....what....oh sh*t.......splat"


        I'm not really a human, but I play one on earth. flash japh