How to update perl module with cpanm - perl

I try to install/update Perl module with cpanm. But, it failed for every modules.
for example:
cpanm Config::General
--> Working on Config::General
Fetching http://www.cpan.org/authors/id/T/TL/TLINDEN/Config-General-2.56.tar.gz ... OK
Configuring Config-General-2.56 ... OK
Building and testing Config-General-2.56 ... OK
Successfully installed Config-General-2.56 (upgraded from 2.52)
1 distribution installed
So, i expect that version of Config::General is now 2.56, but... :
perl -e 'use Config::General 2.56'
Config::General version 2.56 required--this is only version 2.52 at -e line 1.
I try the same logged in superU but same problem...
But now, i have Perl lib in
~/perl5/lib/perl5/ and /usr/lib/perl/5.18/
How can i properly update Perl modules with cpanm?
Some information about my install:
$ perl -E'
say "$_=$ENV{$_}" for qw( PERL_MM_OPT PERL_MB_OPT PERL5LIB );
say "--";
say for #INC;
'
PERL_MM_OPT=INSTALL_BASE=/home/hacklionex/perl5
PERL_MB_OPT=--install_base "/home/hacklionex/perl5"
PERL5LIB=
--
/etc/perl
/usr/local/lib/perl/5.18.2
/usr/local/share/perl/5.18.2
/usr/lib/perl5
/usr/share/perl5
/usr/lib/perl/5.18
/usr/share/perl/5.18
/usr/local/lib/site_perl
.

Your are instructing the module installers to install modules in /home/hacklionex/perl5 (via PERL_MM_OPT and PERL_MB_OPT), but you don't tell Perl to look for modules there (it's not in #INC). Add the following to your login script:
export PERL5LIB=/home/hacklionex/perl5/lib/perl5
Or add the following to your script:
use lib '/home/hacklionex/perl5/lib/perl5';

Related

Perlbrew switch fails on docker build [duplicate]

I'd like to use fast cpm module installer instead of cpanm in my projects.
Also I install target perl version using perlbrew.
According documentation of cpm -g option will install modules into current #INC
How to force perlbrew change #INC in Dockerfile ?
Below is part of my Dockerfile
RUN perl -le 'print for #INC' && \
perlbrew switch perl-5.31.0 && \
perl -le 'print for #INC' && \
cpm install -gv CGI && \
perlbrew list-modules
When I build Dockerfile output of perl -le 'print for #INC' is same both times:
/etc/perl
/usr/local/lib/x86_64-linux-gnu/perl/5.22.1
/usr/local/share/perl/5.22.1
/usr/lib/x86_64-linux-gnu/perl5/5.22
/usr/share/perl5
/usr/lib/x86_64-linux-gnu/perl/5.22
/usr/share/perl/5.22
/usr/local/lib/site_perl
/usr/lib/x86_64-linux-gnu/perl-base
But if I do same manually result is ok:
$ docker run -it pavelsr/xxxhub
root#1a34ea34a3fb:/# perl -le 'print for #INC'
/etc/perl
/usr/local/lib/x86_64-linux-gnu/perl/5.22.1
/usr/local/share/perl/5.22.1
/usr/lib/x86_64-linux-gnu/perl5/5.22
/usr/share/perl5
/usr/lib/x86_64-linux-gnu/perl/5.22
/usr/share/perl/5.22
/usr/local/lib/site_perl
/usr/lib/x86_64-linux-gnu/perl-base
.
root#1a34ea34a3fb:/# perlbrew switch perl-5.31.0
A sub-shell is launched with perl-5.31.0 as the activated perl. Run 'exit' to finish it.
root#1a34ea34a3fb:/# perl -le 'print for #INC'
/usr/local/perlbrew/perls/perl-5.31.0/lib/site_perl/5.31.0/x86_64-linux
/usr/local/perlbrew/perls/perl-5.31.0/lib/site_perl/5.31.0
/usr/local/perlbrew/perls/perl-5.31.0/lib/5.31.0/x86_64-linux
/usr/local/perlbrew/perls/perl-5.31.0/lib/5.31.0
root#1a34ea34a3fb:/# cpm install -g CGI
DONE install HTML-Tagset-3.20
DONE install HTML-Parser-3.72
DONE install CGI-4.44
3 distributions installed.
root#1a34ea34a3fb:/# perlbrew list-modules
CGI
HTML::Parser
HTML::Tagset
Perl
For starters, "A sub-shell is launched with ..." indicates you have an incorrectly setup perlbrew. You were instructed to add the following to your shell's startup script:
source "${PERLBREW_ROOT:-$HOME/perl5/perlbrew}"/etc/bashrc
Without this, a fallback mechanism is used to try to provide the desired functionality, but it's completely useless outside of interactive shells.
Secondly, this is a rather dubious use of perlbrew. If your docker script worked as intended, it would have far reaching consequences. That's not a good thing. You could use perlbrew use, but you could instead use the correct perl build directly using
RUN "${PERLBREW_ROOT:-$HOME/perl5/perlbrew}"/perls/perl-5.31.0/bin/perl -S cpm install -gv CGI
In your case, this should resolve to
RUN /usr/local/perlbrew/perls/perl-5.31.0/bin/perl -S cpm install -gv CGI
for you.

Install modules with perlbrew and cpm - perlbrew switch does not change #INC during docker build

I'd like to use fast cpm module installer instead of cpanm in my projects.
Also I install target perl version using perlbrew.
According documentation of cpm -g option will install modules into current #INC
How to force perlbrew change #INC in Dockerfile ?
Below is part of my Dockerfile
RUN perl -le 'print for #INC' && \
perlbrew switch perl-5.31.0 && \
perl -le 'print for #INC' && \
cpm install -gv CGI && \
perlbrew list-modules
When I build Dockerfile output of perl -le 'print for #INC' is same both times:
/etc/perl
/usr/local/lib/x86_64-linux-gnu/perl/5.22.1
/usr/local/share/perl/5.22.1
/usr/lib/x86_64-linux-gnu/perl5/5.22
/usr/share/perl5
/usr/lib/x86_64-linux-gnu/perl/5.22
/usr/share/perl/5.22
/usr/local/lib/site_perl
/usr/lib/x86_64-linux-gnu/perl-base
But if I do same manually result is ok:
$ docker run -it pavelsr/xxxhub
root#1a34ea34a3fb:/# perl -le 'print for #INC'
/etc/perl
/usr/local/lib/x86_64-linux-gnu/perl/5.22.1
/usr/local/share/perl/5.22.1
/usr/lib/x86_64-linux-gnu/perl5/5.22
/usr/share/perl5
/usr/lib/x86_64-linux-gnu/perl/5.22
/usr/share/perl/5.22
/usr/local/lib/site_perl
/usr/lib/x86_64-linux-gnu/perl-base
.
root#1a34ea34a3fb:/# perlbrew switch perl-5.31.0
A sub-shell is launched with perl-5.31.0 as the activated perl. Run 'exit' to finish it.
root#1a34ea34a3fb:/# perl -le 'print for #INC'
/usr/local/perlbrew/perls/perl-5.31.0/lib/site_perl/5.31.0/x86_64-linux
/usr/local/perlbrew/perls/perl-5.31.0/lib/site_perl/5.31.0
/usr/local/perlbrew/perls/perl-5.31.0/lib/5.31.0/x86_64-linux
/usr/local/perlbrew/perls/perl-5.31.0/lib/5.31.0
root#1a34ea34a3fb:/# cpm install -g CGI
DONE install HTML-Tagset-3.20
DONE install HTML-Parser-3.72
DONE install CGI-4.44
3 distributions installed.
root#1a34ea34a3fb:/# perlbrew list-modules
CGI
HTML::Parser
HTML::Tagset
Perl
For starters, "A sub-shell is launched with ..." indicates you have an incorrectly setup perlbrew. You were instructed to add the following to your shell's startup script:
source "${PERLBREW_ROOT:-$HOME/perl5/perlbrew}"/etc/bashrc
Without this, a fallback mechanism is used to try to provide the desired functionality, but it's completely useless outside of interactive shells.
Secondly, this is a rather dubious use of perlbrew. If your docker script worked as intended, it would have far reaching consequences. That's not a good thing. You could use perlbrew use, but you could instead use the correct perl build directly using
RUN "${PERLBREW_ROOT:-$HOME/perl5/perlbrew}"/perls/perl-5.31.0/bin/perl -S cpm install -gv CGI
In your case, this should resolve to
RUN /usr/local/perlbrew/perls/perl-5.31.0/bin/perl -S cpm install -gv CGI
for you.

Can't locate scripts/Config.pm in #INC (you may need to install the scripts::Config module)

Can't locate scripts/Config.pm in #INC
(you may need to install the scripts::Config module)
(#INC contains:
/etc/perl
/usr/local/lib/x86_64-linux-gnu/perl/5.24.1
/usr/local/share/perl/5.24.1
/usr/lib/x86_64-linux-gnu/perl5/5.24
/usr/share/perl5
/usr/lib/x86_64-linux-gnu/perl/5.24
/usr/share/perl/5.24
/usr/local/lib/site_perl
/usr/lib/x86_64-linux-gnu/perl-base
) at scripts/Training.pl line 54.
(Line breaks added for readability)
I have tried to install the module with cpan install scripts::Config, but it doesn't work.
Loading internal null logger. Install Log::Log4perl for logging messages
Reading '/home/japangly/.cpan/Metadata'
Database was generated on Thu, 03 Jan 2019 13:29:03 GMT
Warning: Cannot install scripts::Config, don't know what it is.
Try the command
i /scripts::Config/
to find objects with matching identifiers.
I tried to create links in /usr/local but it is empty:
ln -s /usr/{,local/}lib/perl5/5.8.3
ln -s /usr/{,local/}lib/perl5/site_perl/5.8.3
https://www.perlmonks.org/?node_id=746288
I use google cloud platform:
$ which perl /usr/bin/perl
$ perl -e "print join(\"\n\", #INC);"
/etc/perl
/usr/local/lib/x86_64-linux-gnu/perl/5.24.1
/usr/local/share/perl/5.24.1
/usr/lib/x86_64-linux-gnu/perl5/5.24
/usr/share/perl5
/usr/lib/x86_64-linux-gnu/perl/5.24
/usr/share/perl/5.24
/usr/local/lib/site_perl
/usr/lib/x86_64-linux-gnu/perl-base
The error message is:
Can't locate scripts/Config.pm ... at scripts/Training.pl line 54
The lines 53 and 54 look like
#line 53
$| = 1; if ( #ARGV < 1 ) { print "usage: Training.pl Config.pm\n"; exit(0); } # load configuration variables
require( $ARGV[0] );
The script expects to be run from the directory where the file Config.pm exists. Maybe alternatively you can run it as perl scripts/Training.pl scripts/Config.pm or put Config.pm into the current directory instead of having it in scripts/.
You might want to add . to the module search path by adding the following line to scripts/Training.pl, to future-proof it when upgrading Perl from 5.24 to a newer version:
use lib '.';

unavailable cpan in cygwin

I have unsuccessfully tried to install Perl module in cygwin like in an answer. I have got the following error:
$ perl -MCPAN -e shell
Can't locate CPAN.pm in #INC (you may need to install the CPAN module) (#INC contains: /usr/lib/perl5/site_perl/5.22/x86_64-cygwin-threads /usr/lib/perl5/site_perl/5.22 /usr/lib/perl5/vendor_perl/5.22/x86_64-cygwin-threads /usr/lib/perl5/vendor_perl/5.22 /usr/lib/perl5/5.22/x86_64-cygwin-threads /usr/lib/perl5/5.22 .).
BEGIN failed--compilation aborted.
How can I obtain cpan in my cygwin?
There are some additional details. Actually my purpose was to install ack like in answer. However, it didn't work. After installing I have got an error:
$ ack
Can't locate filetest.pm in #INC (you may need to install the filetest module) (#INC contains: /usr/lib/perl5/site_perl/5.22/x86_64-cygwin-threads /usr/lib/perl5/site_perl/5.22 /usr/lib/perl5/vendor_perl/5.22/x86_64-cygwin-threads /usr/lib/perl5/vendor_perl/5.22 /usr/lib/perl5/5.22/x86_64-cygwin-threads /usr/lib/perl5/5.22 .) at /home/loom/bin/ack line 218.
BEGIN failed--compilation aborted at /home/loom/bin/ack line 218.
The following was my trying to locate cpan
$ cpan
-bash: cpan: command not found
$ ll /usr/lib/perl5/5.22/CPAN.pm
ls: cannot access '/usr/lib/perl5/5.22/CPAN.pm': No such file or directory
$ find /usr/ -name *.pm | grep CPAN
/usr/lib/perl5/5.22/CPAN/Meta/Converter.pm
/usr/lib/perl5/5.22/CPAN/Meta/Feature.pm
/usr/lib/perl5/5.22/CPAN/Meta/History.pm
/usr/lib/perl5/5.22/CPAN/Meta/Merge.pm
/usr/lib/perl5/5.22/CPAN/Meta/Prereqs.pm
/usr/lib/perl5/5.22/CPAN/Meta/Requirements.pm
/usr/lib/perl5/5.22/CPAN/Meta/Spec.pm
/usr/lib/perl5/5.22/CPAN/Meta/Validator.pm
/usr/lib/perl5/5.22/CPAN/Meta/YAML.pm
/usr/lib/perl5/5.22/CPAN/Meta.pm
/usr/lib/perl5/5.22/Parse/CPAN/Meta.pm
Reinstalling perl helped.
$ apt-cyg install perl

Bash error in perl script using HTML::Scrubber

USER:~/Directory>curl http://www.w3schools.com/html/html_tables.asp | html.parser2.pl
Can't locate HTML/Scrubber.pm in #INC (#INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5 /usr/share/perl5 /usr/lib64/perl5 /usr/share/perl5 /usr/local/lib64/perl5/site_perl/5.10.0/x86_64-linux-thread-multi /usr/local/lib/perl5/site_perl/5.10.0 /usr/lib64/perl5/vendor_perl/5.10.0/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl /usr/lib/perl5/site_perl .) at ./html.parser2.pl line 2.
BEGIN failed--compilation aborted at ./html.parser2.pl line 2.
What's happening here?
What's happening is that perl can't find the HTML::Scrubber module, which is required somewhere in the html.parser2.pl script.
Usually, the fix is to install it with cpan
cpan HTML::Scrubber
or possibly one of
sudo cpan HTML::Scrubber
<perl> -MCPAN -e 'install "HTML::Scrubber"'
where <perl> is the full path to the version of perl in the html.parser2.pl script's shebang line.
This solution might not work for a number of reasons (cpan can fail building and installing the module, you have more than one version of perl on your system and you are installing the module in the "wrong" version, ...). If cpan doesn't fix your problem, ask another question here including all the relevant output from the cpan process and from your command line invocation of the script.