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?
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:
- Grabs the specified Perl source
- Builds it with the specified switches in the given directory
- 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:
- Does it work?
- Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
| [reply] [Watch: Dir/Any] |
|
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?
| [reply] [Watch: Dir/Any] |
|
| [reply] [Watch: Dir/Any] [d/l] |
|
Where would I put the script? Should this be something I upload to CPAN?
My criteria for good software:
- Does it work?
- Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
| [reply] [Watch: Dir/Any] |
|
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.
| [reply] [Watch: Dir/Any] [d/l] |
|
| [reply] [Watch: Dir/Any] |
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
| [reply] [Watch: Dir/Any] |
|
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. | [reply] [Watch: Dir/Any] [d/l] [select] |
Re: When you change Perl versions, how do you resync all the CPAN modules you have installed [tag://sysadmin,cpan,modules,upgrade]
by jimav (Sexton) on Jul 27, 2017 at 03:15 UTC
|
The OP asked how to recompile modules installed from CPAN, not how to change their entire methodology! Every CPAN user eventually runs into this problem after an OS update which replaces the perl binary.
(unset PERL5LIB; cpan -r)
cpan -r recompiles all XS modules. Unsetting PERL5LIB first ensures that the build tools won't try to use your locally-installed modules, which aren't working yet.
This might not be enough, because some modules depend on internals of the perl executable, and will complain if they find that perl is not a supported version (e.g., it is newer than any version the module understands). The solution is to update the offending CPAN module to the latest version, which presumably supports your new perl executable:
(unset PERL5LIB; cpan install modulename)
If it isn't obvious which module is complaining, you can usually figure it out by running
strace -e open the-command-which-fails
Finally, an alternative to all of the above is to update all your CPAN modules to the latest versions and rebuild them:
(unset PERL5LIB; cpan -u)
However, this can completely hose your setup if CPAN is not currently in a consistent state. Many people don't recommend doing this without first making a backup copy of $HOME/.cpan .
| [reply] [Watch: Dir/Any] [d/l] [select] |
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.
| [reply] [Watch: Dir/Any] |
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
| [reply] [Watch: Dir/Any] |
Re: When you change Perl versions, how do you resync all the CPAN modules you have installed [tag://sysadmin,cpan,modules,upgrade]
by snoopy (Curate) 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
| [reply] [Watch: Dir/Any] [d/l] [select] |
|
|