[CentOS] CPAN not working, or is it?

Mon Mar 11 20:57:27 UTC 2019
Warren Young <warren at etr-usa.com>

On Mar 11, 2019, at 8:01 AM, Gary Stainburn <gary.stainburn at ringways.co.uk> wrote:
> 
> Anyone got any ideas what  I need to do?

First, use cpanm instead of the old cpan shell:

    $ sudo yum install perl-App-cpanminus

It has a number of advantages:

1. It’s much smarter about chasing dependencies, which is your core problem here.

2. It autoconfigures, not requiring all that outdated stuff about “where is your FTP program,” “what mirror should I use,” and such.

3. It’s easy to feed it a cpanfile with a curated set of dependencies for a one-command “install everything I need here” upgrade:

    https://metacpan.org/pod/distribution/Module-CPANfile/lib/cpanfile.pod

4. When it fails, it keeps its output in a log file that’s easy to send to mailing lists when asking for help.  Hint. :)

> I started off as always by using RPM's for everything I possibly can.

I try to do that, too.  The claim in another reply that RPM CPAN modules and cpan- or cpanm-installed modules cannot work together is incorrect.

What is correct is that the CentOS-provided RPMs are often sufficiently outdated that they no longer work with the latest releases that cpanm wants to download by default.  The older the CentOS installation, the greater the chance of this happening, and the greater the chance that it will happen to a module that’s so deeply tied into your dependency tree that it seems to break everything.

There are three main solutions:

1. Tell cpanm to download an older version that works with the other RPM-installed CPAN modules:

    $ sudo cpanm Foo::Bar at 1.2.3

1b: Same thing, but in cpanfile syntax:

    requires 'Foo::Bar', ‘== 1.2.3';

cpanfile is very flexible and can be given much more granular rules; see the link above.

2. Selectively remove CPAN modules installed via RPM that conflict and let cpanm upgrade you to the latest.  This works as long as the newer modules are upwards compatible with the remaining RPM-installed CPAN modules.

3. Use a system like App::Fatpacker or Carton to bundle your app and its dependencies into a self-contained bundle that doesn’t depend on system CPAN modules:

    https://metacpan.org/release/Carton
    https://metacpan.org/pod/App::FatPacker

I prefer using Carton with cpanfile, but others prefer the way App::Fatpacker works.