Home > Software engineering >  Problem installing modules with cpanm in Perl
Problem installing modules with cpanm in Perl

Time:06-26

I am absolutely new to Perl world. I've picked up a project left behind by a former employee & trying to get it to work. The project was originally in docker form & the requirement now is to run it in a non-docker form (don't get me started on this!) The project works like a charm in it's docker form. I've made the assumption that if I were to install all the packages installed in the docker file, the script should work. In the process of installing the packages, I am bumping into issues.

While the docker image uses ubuntu, the server I am trying on now uses RHEL7

DOCKER FILE

FROM ubuntu:focal-20200703 as ubuntu
FROM ubuntu as mytool

ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y -qq build-essential libssl-dev tzdata bash curl wget perl cpanminus libcrypt-ssleay-perl libnet-ssleay-perl
RUN cpanm -n Data::Printer \
             Log::Log4perl \
             List::Util \
             Test::More \
             JSON \
             JSON::XS \
             YAML \
             YAML::XS \
             GitLab::API::v4 \
             IO::Socket::SSL \
             HTML::HashTable \
             REST::Client \
             MIME::Base64 \
             File::Spec \
             File::Basename \
             File::Path \
             List::MoreUtils \
             DateTime::Format::ISO8601 \
             Digest::MD5

ENV TZ=Pacific/Auckland
RUN echo $TZ > /etc/timezone && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime

COPY docker/context/usr/local/bin/entrypoint.sh /usr/local/bin/entrypoint.sh
COPY docker/context/usr/local/etc/mytool/mytool.env.ctmpl /usr/local/etc/mytool/mytool.env.ctmpl

RUN mkdir -p /usr/local/bin /usr/local/bin/cache.d
WORKDIR /usr/local/bin

COPY mytool /usr/local/bin/
COPY lib/ /usr/local/bin/lib

# Container pilot obligatory parameters START
ENV SERVICE_NAME=mytool
ENV SERVICE_PRE_EXEC=/bin/true
ENV SERVICE_HEALTHCHECK_EXEC="test -f /usr/local/etc/mytool/mytool.env"
ENV SERVICE_TEMPLATE_CONFIG_PAIRS=/usr/local/etc/mytool/mytool.env.ctmpl:/usr/local/etc/mytool/mytool.env
EXPOSE 8080

ENTRYPOINT [""]
CMD ["/usr/local/bin/entrypoint.sh"]
# Container pilot obligatory parameters END

I've installed build-essential libssl-dev tzdata bash curl wget perl cpanminus libcrypt-ssleay-perl libnet-ssleay-perl successfully.

Problem is with cpanm stuff from the docker file

[root@npcrver01 home]# cpanm Log::Log4perl
! Finding Log::Log4perl on cpanmetadb failed.
! cannot open file '/root/.cpanm/sources/http%www.cpan.org/02packages.details.txt.gz': No such file or directory opening compressed index
! Couldn't find module or a distribution Log::Log4perl ()

Please could someone help me here

CodePudding user response:

gosh it's the proxy setting. I had to do

export https_proxy=http://<IP>:<port>
export http_proxy=http://<IP>:<port>
export HTTPS_PROXY=http://<IP>:<port>
export HTTP_PROXY=http://<IP>:<port>

Everything is working fine now

  •  Tags:  
  • perl
  • Related