Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

When you change Perl versions, how do you resync all the CPAN modules you have installed [tag://sysadmin,cpan,modules,upgrade]

by metaperl (Curate)
on Nov 13, 2007 at 21:13 UTC ( #650603=perlquestion: print w/ replies, xml ) Need Help??
metaperl has asked for the wisdom of the Perl Monks concerning the following question:

When Debian upgrades my Perl version, it will no longer find the modules I had installed with my older version of Perl.

Then all sorts of things start breaking due to modules not being available.

What solutions do you have to this earth-shattering dilemma?

Comment on When you change Perl versions, how do you resync all the CPAN modules you have installed [tag://sysadmin,cpan,modules,upgrade]
Re: When you change Perl versions, how do you resync all the CPAN modules you have installed [tag://sysadmin,cpan,modules,upgrade]
by samtregar (Abbot) on Nov 13, 2007 at 21:23 UTC
    Then all sorts of things start breaking due to modules not being available.

    That's not always true, although it depends on what version you're upgrade to/from. Standard Perl practice is to include in the @INC paths the paths from prior compatible versions.

    If you do need to reinstall your modules then want to make a list of them and feed them to CPAN.pm. I'm sure someone has a clever one-liner for that, but I can cook something up for you if nobody does.

    BTW, what's that tag:// junk at the end of your title?

    -sam

      perl -MCPAN -e autobundle

      But I would never upgrade the system Perl without proper testing, and blindly upgrading a whole system sounds very fraught with errors to me. Compiling your own Perl is easy, even on Win32 nowadays, and there's no reason to use the system Perl when you're not installing modules using the packaging tool of the system as well. Under Debian, this means apt-get of course.

Re: When you change Perl versions, how do you resync all the CPAN modules you have installed [tag://sysadmin,cpan,modules,upgrade]
by dragonchild (Archbishop) on Nov 13, 2007 at 21:29 UTC
    I have a script that I use to build the Perl environment for my applications. I never install stuff in the system Perl - that's for the system. So, when I want to upgrade Perl, I just rerun the script which does the following:
    1. Grabs the specified Perl source
    2. Builds it with the specified switches in the given directory
    3. Installs a list of CPAN modules with that specific perl

    Remember - you're wondering about maintenance of a scripting language. You use it for automating all your other sysadmin tasks . . .


    My criteria for good software:
    1. Does it work?
    2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
      Could you share the script? Moreover, I compiled perl by myself some time ago, but I don't remember which switches I used. Is there somewhere I can look for this info?

      Flavio
      perl -ple'$_=reverse' <<<ti.xittelop@oivalf

      Io ho capito... ma tu che hai detto?

        perl -V (that's a capital V) should tell you most, if not all, of what you need to know.

        Where would I put the script? Should this be something I upload to CPAN?

        My criteria for good software:
        1. Does it work?
        2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
Re: When you change Perl versions, how do you resync all the CPAN modules you have installed [tag://sysadmin,cpan,modules,upgrade]
by tirwhan (Abbot) on Nov 13, 2007 at 22:10 UTC

    You should use the Debian package management system (apt-get) to install your modules, same as you do for all other software. For modules not available in the Debian distribution, use dh-make-perl to download, build and install the module from CPAN, it creates a proper .deb package which can then be managed via the apt tools.


    All dogma is stupid.
Re: When you change Perl versions, how do you resync all the CPAN modules you have installed [tag://sysadmin,cpan,modules,upgrade]
by sundialsvc4 (Abbot) on Nov 14, 2007 at 19:27 UTC

    Start with perl -V (uppercase "V") and look at the @INC list. When Perl looks for a library, that's where it looks and in what order.

    The base list is hard-coded into the Perl module when it is compiled. It customarily includes both site_perl and vendor_perl directories, although distributions do vary as to which one comes first.

    An environment variable such as PERL5LIB can be used to insert other paths into the front of this list, and that's what I've chosen to do. For my personal uses of Perl, I've got my personal PERL5LIB list, established by a .bashrc script. (Both Windows and OS/X have comparable mechanisms... see e.g. perldoc perlport.)

    I've got "my own, personal" CPAN-setup too, and it has such o conf settings as (I think) PROFILE which cause all of the builds to be directed to the right place. Since these are my personal settings (as reflected in the hidden .cpan directory of my own login account), they affect only me.

    When I'm doing system maintenance, my PERL5LIB settings are nowhere in sight: I use an entirely different, more-privileged login for system maintenance that is not "root-ly," and of course I also do use root. None of those see any settings other than the system-default; they use their own .cpan settings in their own home-directories, and those settings are the ones that are established by my distro-vendor (Gentoo).

    Incidentally, this mechanism works really well because a lot of my Perl work deals with web-sites. I set up a different login for each web-project for use when I'm working on that one. The settings such as PERL5LIB, and the site-directory structures, are always exactly what needs to be rsync'd up to the corresponding web-site. This keeps the settings for each site at a good arm's-length from one another, as well as from the system. Gentoo can do whatever updates it needs to, and it won't hurt me and I won't hurt them. Likewise, I can make changes needed for client-X which runs on perl-Y on computer-Z without scribbling on the stuff for some other client.

    Perl's backers might or might not be adept at advertising (or explaining) all the subtle things they've thought-of, but darned if they didn't think about 'em! Of course, given that Perl runs in as many different environments as it does, you should expect it.

Re: When you change Perl versions, how do you resync all the CPAN modules you have installed [tag://sysadmin,cpan,modules,upgrade]
by marky1124 (Novice) on Sep 09, 2009 at 12:51 UTC

    I have also been hit by this problem on a Debian upgrade from Etch (perl-modules v5.8.8-7etch7) to Lenny (perl-modules v5.10.0-19lenny2).

    I accept the comments above regarding not using the system perl are valid in terms of keep tight control of an application environment.

    However that said I feel that the upgrade from perl v5.8 to v5.10 should still be handled differently. For one it deleted my /usr/local/share/perl/5.8.8 directory structure which had been built by me installing modules using "perl -MCPAN -e shell". Given that none of the Debian perl packages populated /usr/local/share/perl/5.8.8 I feel hard done by that the upgrade deleted them.

    In addition the perl upgrade could display a notification of this situation. It could go further and even pull in new CPAN modules automatically to match. That might be too much to automate, but I do feel that it could do more to assist the person doing the upgrade.

    All the best,
    Cheers,
    Mark

Re: When you change Perl versions, how do you resync all the CPAN modules you have installed [tag://sysadmin,cpan,modules,upgrade]
by snoopy (Deacon) on Sep 10, 2009 at 01:46 UTC
    At all times, I maintain a Module::Build's OO interface to produce a report of required modules. This can be used in any situation where I need to rebuild/upgrade/recover in a hurry.

    For example:

    #!/usr/bin/perl use common::sense; use Module::Build; use Sys::Hostname qw/hostname/; my $build = Module::Build->new ( module_name => 'DLS', license => 'perl', requires => { 'perl' => '5.8.0', 'CGI' => '3.11', 'ACME::EyeDrops' => '1.23', }, dist_version => 0.1, ); print "CPAN Dependencies for ".hostname()."\n"; print "=============================================\n"; print $build->prereq_report;
    Then on my target machine:
    snoopy@snoopy-laptop:~$ perl cpan_deps.pl 2>/dev/null Checking prerequisites... CPAN Dependencies for snoopy-laptop ===================================== requires: Module Need Have -----------------+---------+---------- ! ACME::EyeDrops 1.23 <none> CGI 3.11 3.42 perl 5.8.0 5.10.0

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://650603]
Approved by GrandFather
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2014-09-22 00:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (176 votes), past polls