Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why should I not update all my CPAN modules?

Tags:

perl

updates

cpan

I thought it would be a good idea in general to update all software on my computer regularly. Since CPAN modules are not managed by my package manager I figured I should do cpan -u every once in a while. It was only after executing this that I read the man page note on this:

-u  Upgrade all installed modules. Blindly doing this can really break
   things, so keep a backup.
  1. Why should this break anything? And how should I keep my CPAN modules up to date otherwise; do I need to keep track of all manually installed modules (cpan doesn't seem to do this) and only update those regularly? How about the dependencies of my manually installed modules?
  2. Why did cpan -u upgrade stuff for ~15min even though I haven't installed a single CPAN module?
  3. Can I revert the cpan -u? Is it enough to delete ~/.cpan for this?
like image 447
J. Doe Avatar asked Oct 04 '18 14:10

J. Doe


People also ask

What is the difference between CPAN and cpanm?

The main difference between the two is that if you have Perl you should already have the cpan command. Whereas you won't have cpanm unless/until you install it.

What is the use of CPAN?

CPAN can denote either the archive network or the Perl program that acts as an interface to the network and as an automated software installer (somewhat like a package manager). Most software on CPAN is free and open source software.

Where do CPAN modules get installed?

CPAN doesn't actually install files. It runs the install script embedded in each distribution, which then performs the actual install. For distributions using ExtUtils::MakeMaker, the defaults are documented here: https://metacpan.org/pod/ExtUtils::MakeMaker#make-install (and the default value of INSTALLDIRS is site ).

What is CPAN Module in Perl?

Various Perl modules are available on the Comprehensive Perl Archive Network (CPAN). These modules cover a wide range of categories such as network, CGI, XML processing, databases interfacing, etc. Creating a Perl Module. A modules name must be same as to the name of the Package and should end with . pm extension.


2 Answers

Why should this break anything?

It shouldn't, but complex systems are complex and sometimes things do break (e.g. if a module is updated with a non-backwards compatible change, or depends on a C library which has bugs which only show up in combination with specific dependencies).

And how should I keep my CPAN modules up to date otherwise;

Just keep backups in case things break.

Why did cpan -u upgrade stuff for ~15min even though I haven't installed a single CPAN module?

Perl is distributed with a large collection of modules, and other modules may have been installed by your distribution.

Can I revert the cpan -u?

You can overwrite it with the backup that the documentation recommended you take.

Is it enough to delete ~/.cpan for this?

No. That directory is used by the installer tool to cache data about available modules, to store source code, and to hold build artefacts. The installed files are written to your lib like any other library.

like image 190
Quentin Avatar answered Nov 15 '22 06:11

Quentin


  1. New or update code is new or updated bugs. I have the opposite view of Quentin: why would changing a bunch of stuff keep not break things? That's what I expect with most updates. However, the Perl 5 porters take great pains to test perl distributions against as much of CPAN as they can. That doesn't mean that your particular use of a module (and how you've worked around existing bugs) is stable.

  2. Some modules that come with perl are also on CPAN. These are "dual-lived" modules and they might update from CPAN.

  3. The cpan tool doesn't revert anything for you, but you can do what I do sometimes. Make your installation a git repo. Branch when you change it. Try the branch with your code. If anything goes wrong you can always switch back to master. You don't even need to commit the changes! Tools such as Pinto help you manage sets of Perl modules.


There are some other things to consider.

First, I recommend that you don't mess with the system perl. Let the system do that. If you want a fresher perl that you manage yourself, install a different one. You might like perlbrew for that (I don't, but that's no big deal).

You can screw up that one as much as you like and the system won't start doing weird things. Consider major changes like removing . from @INC and Deprecating unescaped left braces in regexes. Those were changes in perl but they broke some important things.

Second, you can configure cpan to install somewhere besides the system directories. The -I switch will use local::lib for you. Besides that, you can configure it manually.

like image 25
brian d foy Avatar answered Nov 15 '22 05:11

brian d foy