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.
Related
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.
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
I am trying to write a small code but as soon as i am importing "Selenium::Remote::Driver:", i get an error stating
"Can't locate Selenium/Remote/Driver.pm in #INC"
I have tried installing it using below command
sudo apt-get install libtest-www-selenium-perl
still i get same error
$ perl -e 'use Selenium::Remote::Driver;'
Can't locate Selenium/Remote/Driver.pm in #INC (you may need to install the Selenium::Remote::Driver module) (#INC contains: /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 .) at -e line 1.
BEGIN failed--compilation aborted at -e line 1.
Selenium::Remote::Driver is not part of Test::WWW::Selenium. From the documentation:
Installation
It's probably easiest to use the cpanm or CPAN
commands: bash $ cpanm Selenium::Remote::Driver
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';
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.