Perl: Instalación de dependencias con CPAN

Al intentar instalar algunas dependencias de perl a través de CPAN recibí el siguiente error:

1
2
3
[root@DJANGO /]# perl -MCPAN -e "install 'Data::Dumper'"
Can't locate CPAN.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .).
BEGIN failed--compilation aborted.

El error indica que no está instalado, o configurado, CPAN; la solución es muy sencilla:

  1. Instalar: yum install perl-CPAN.
  2. Configurar: perl -MCPAN -e shell.

Ejemplo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
[root@DJANGO /]# yum install -y perl-CPAN >/dev/null
[root@DJANGO /]# perl -MCPAN -e shell
CPAN.pm requires configuration, but most of it can be done automatically. If you answer 'no' below, you will enter an interactive dialog for each configuration option instead.
Would you like to configure as much as possible automatically? [yes]
<install_help>
Warning: You do not have write permission for Perl library directories.
To install modules, you need to configure a local Perl library directory or escalate your privileges. CPAN can help you by bootstrapping the local::lib module or by configuring itself to use 'sudo' (if available). You may also resolve this problem manually if you need to customize your setup.
What approach do you want? (Choose 'local::lib', 'sudo' or 'manual') [local::lib]
Autoconfigured everything but 'urllist'.
Now you need to choose your CPAN mirror sites. You can let me pick mirrors for you, you can select them from a list or you can enter them by hand.
Would you like me to automatically choose some CPAN mirror sites for you? (This means connecting to the Internet) [yes]
Trying to fetch a mirror list from the Internet Fetching with HTTP::Tiny:
http://www.perl.org/CPAN/MIRRORED.BY
Looking for CPAN mirrors near you (please be patient)
......................... done!
New urllist
http://cpan.cu.be/
http://mirror.transip.net/CPAN/
http://www.cpan.dk/
Autoconfiguration complete.

Por último solo es necesario recargar las variables de entorno con source ~/.bashrc y volver a instalar la dependencia.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
[root@DJANGO /]# perl -MCPAN -e "install 'Data::Dumper'"
Reading '/root/.cpan/Metadata'
Database was generated on Thu, 31 Mar 2016 18:17:02 GMT
Running install for module 'Data::Dumper'
Running make for S/SM/SMUELLER/Data-Dumper-2.154.tar.gz
Checksum for /root/.cpan/sources/authors/id/S/SM/SMUELLER/Data-Dumper-2.154.tar.gz ok
CPAN.pm: Building S/SM/SMUELLER/Data-Dumper-2.154.tar.gz
Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for Data::Dumper
Writing MYMETA.yml and MYMETA.json
cp Dumper.pm blib/lib/Data/Dumper.pm
Running Mkbootstrap for Data::Dumper ()
chmod 644 "Dumper.bs"
"/usr/bin/perl" "/usr/share/perl5/vendor_perl/ExtUtils/xsubpp" -typemap "/usr/share/perl5/ExtUtils/typemap" Dumper.xs > Dumper.xsc && mv Dumper.xsc Dumper.c
gcc -c -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -DVERSION=\"2.154\" -DXS_VERSION=\"2.154\" -fPIC "-I/usr/lib64/perl5/CORE" -DUSE_PPPORT_H Dumper.c
rm -f blib/arch/auto/Data/Dumper/Dumper.so
gcc -shared -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -Wl,-z,relro Dumper.o -o blib/arch/auto/Data/Dumper/Dumper.so \
\
chmod 755 blib/arch/auto/Data/Dumper/Dumper.so
"/usr/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- Dumper.bs blib/arch/auto/Data/Dumper/Dumper.bs 644
SMUELLER/Data-Dumper-2.154.tar.gz
/usr/bin/make -- OK
'YAML' not installed, will not store persistent state
Running make test
Running Mkbootstrap for Data::Dumper ()
chmod 644 "Dumper.bs"
PERL_DL_NONLAZY=1 "/usr/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/bless.t ..................... ok
t/bless_var_method.t .......... ok
t/bugs.t ...................... ok
t/deparse.t ................... ok
t/dumper.t .................... ok
t/dumpperl.t .................. ok
t/freezer.t ................... ok
t/freezer_useperl.t ........... ok
t/indent.t .................... ok
t/misc.t ...................... ok
t/names.t ..................... ok
t/overload.t .................. ok
t/pair.t ...................... ok
t/perl-74170.t ................ ok
t/purity_deepcopy_maxdepth.t .. ok
t/qr.t ........................ ok
t/quotekeys.t ................. ok
t/recurse.t ................... ok
t/seen.t ...................... ok
t/sortkeys.t .................. ok
t/sparseseen.t ................ ok
t/terse.t ..................... ok
t/toaster.t ................... ok
t/values.t .................... ok
All tests successful.
Files=24, Tests=723, 3 wallclock secs ( 0.17 usr 0.02 sys + 1.22 cusr 0.18 csys = 1.59 CPU)
Result: PASS
SMUELLER/Data-Dumper-2.154.tar.gz
/usr/bin/make test -- OK
Running make install
Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
Installing /root/perl5/lib/perl5/x86_64-linux-thread-multi/auto/Data/Dumper/Dumper.so
Installing /root/perl5/lib/perl5/x86_64-linux-thread-multi/Data/Dumper.pm
Appending installation info to /root/perl5/lib/perl5/x86_64-linux-thread-multi/perllocal.pod
SMUELLER/Data-Dumper-2.154.tar.gz
/usr/bin/make install -- OK
Contenidos
  1. 1. Ejemplo