Skip to content

Perl version of 5.24 is inconsistent with debian perl package version (which is also installed). #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pergh opened this issue Oct 4, 2016 · 11 comments

Comments

@pergh
Copy link

pergh commented Oct 4, 2016

This means that if you pull perl modules through apt-get, they will be installed for perl version 5.20, not 5.24. The perl 5.24 version which is first in the path, must have its packages installed through cpan to work.

Suggest you use either debian packaged version 5.20, or remove it and install perl 5.24 only. Having both will probably cause confusion.

@zakame
Copy link
Member

zakame commented Oct 4, 2016

@pergh thanks for the report! I think the Docker Hub documentation and README here can be improved towards indicating the use and priority of the perl installed from source tarball over the Debian system perl (as I think it was an implicit expectation in here and in other language images that the language runtime comes from a source install.)

Let me see about removing the Debian perl as well (though I reckon that might be trickier due to some of Debian's scripts depending on a /usr/bin/perl directly, and I'm loathe to simply symlink a new perl into /usr/bin just so.)

@zakame
Copy link
Member

zakame commented Oct 4, 2016

Hmm so removing perl will try to remove git as well:

#+BEGIN_SRC sh :results output
docker run --rm perl:latest /usr/bin/apt-get autoremove -s perl 
#+END_SRC

#+RESULTS:
#+begin_example
Reading package lists...
Building dependency tree...
Reading state information...
The following packages will be REMOVED:
  autoconf automake git git-man libcurl3-gnutls liberror-perl libgdbm3
  libsigsegv2 m4 perl perl-modules
0 upgraded, 0 newly installed, 11 to remove and 0 not upgraded.
Remv automake [1:1.14.1-4+deb8u1]
Remv autoconf [2.69-8]
Remv git [1:2.1.4-2.1+deb8u2]
Remv git-man [1:2.1.4-2.1+deb8u2]
Remv libcurl3-gnutls [7.38.0-4+deb8u4]
Remv liberror-perl [0.17-1.1]
Remv perl [5.20.2-3+deb8u6]
Remv libgdbm3 [1.8.3-13.1]
Remv m4 [1.4.17-4]
Remv libsigsegv2 [2.10-4+b1]
Remv perl-modules [5.20.2-3+deb8u6]
#+end_example

Setting aside for the moment that the git install comes from our Docker buildpack-deps image inheritance, it seems probably be more worthwhile to be explicit documenting our preferred perl install in /usr/local/bin.

@pjlsergeant
Copy link

I have a problem I think is related. I need to install postgres so that some of my Test::Postgres tests can run. Trying to do this via apt:

FROM perl:5.20

RUN apt-get update \
    && apt-get install -y postgresql \
    && rm -fr /var/lib/apt/lists/*

I'm getting:

Setting up postgresql-9.4 (9.4.9-0+deb8u1) ...
Can't locate PgCommon.pm in @INC (you may need to install the PgCommon module) (@INC contains: /usr/share/postgresql-common /usr/local/lib/perl5/site_perl/5.20.3/x86_64-linux /usr/local/lib/perl5/site_perl/5.20.3 /usr/local/lib/perl5/5.20.3/x86_64-linux /usr/local/lib/perl5/5.20.3 .).
BEGIN failed--compilation aborted.

At first glance, I reckon that's a related issue to:

https://bugs.launchpad.net/ubuntu/+source/postgresql-common/+bug/1407744

@zakame
Copy link
Member

zakame commented Nov 10, 2016

@pjlsergeant thanks, and yes, you could set a PERL5LIB environment variable in your Dockerfile to add Debian's /usr/share/perl5 on perl-5.20's @INC, like so:

FROM perl:5.20
ENV PERL5LIB /usr/share/perl5
RUN apt-get update && apt-get -y install postgresql

This should allow you to install postgresql:

#+BEGIN_SRC sh :results output :exports both
exec 2>&1
docker build -t perl-pg-test .
:
#+END_SRC

#+RESULTS:
#+begin_example
Sending build context to Docker daemon 18.43 kB

Step 1 : FROM perl:5.20
 ---> bbe5a82c1dbe
Step 2 : ENV PERL5LIB /usr/share/perl5
 ---> Running in caecad66f85e
 ---> 0caffbd09672
Removing intermediate container caecad66f85e
Step 3 : RUN apt-get update && apt-get -y install postgresql
 ---> Running in 9e74bd9a0915
Get:1 http://httpredir.debian.org jessie-updates InRelease [145 kB]
Get:2 http://security.debian.org jessie/updates InRelease [63.1 kB]
Get:3 http://security.debian.org jessie/updates/main amd64 Packages [402 kB]
Ign http://httpredir.debian.org jessie InRelease
Get:4 http://httpredir.debian.org jessie-updates/main amd64 Packages [17.6 kB]
Get:5 http://httpredir.debian.org jessie Release.gpg [2373 B]
Get:6 http://httpredir.debian.org jessie Release [148 kB]
Get:7 http://httpredir.debian.org jessie/main amd64 Packages [9064 kB]
Fetched 9843 kB in 23s (411 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
  bsd-mailx cron exim4 exim4-base exim4-config exim4-daemon-light
  init-system-helpers liblockfile-bin liblockfile1 libpopt0 libpq-dev libpq5
  locales logrotate lsb-release postgresql-9.4 postgresql-client-9.4
  postgresql-client-common postgresql-common psmisc ssl-cert
Suggested packages:
  anacron checksecurity mail-reader eximon4 exim4-doc-html exim4-doc-info
  spf-tools-perl swaks postgresql-doc-9.4 lsb postgresql-doc oidentd
  ident-server locales-all openssl-blacklist
Recommended packages:
  mailx
The following NEW packages will be installed:
  bsd-mailx cron exim4 exim4-base exim4-config exim4-daemon-light
  init-system-helpers liblockfile-bin liblockfile1 libpopt0 locales logrotate
  lsb-release postgresql postgresql-9.4 postgresql-client-9.4
  postgresql-client-common postgresql-common psmisc ssl-cert
The following packages will be upgraded:
  libpq-dev libpq5
2 upgraded, 20 newly installed, 0 to remove and 87 not upgraded.
Need to get 12.0 MB of archives.
After this operation, 45.6 MB of additional disk space will be used.
Get:1 http://httpredir.debian.org/debian/ jessie/main init-system-helpers all 1.22 [14.0 kB]
Get:2 http://httpredir.debian.org/debian/ jessie/main cron amd64 3.0pl1-127+deb8u1 [94.0 kB]
Get:3 http://httpredir.debian.org/debian/ jessie/main libpopt0 amd64 1.16-10 [49.2 kB]
Get:4 http://httpredir.debian.org/debian/ jessie/main liblockfile-bin amd64 1.09-6 [18.9 kB]
Get:5 http://httpredir.debian.org/debian/ jessie/main liblockfile1 amd64 1.09-6 [15.8 kB]
Get:6 http://httpredir.debian.org/debian/ jessie/main libpq-dev amd64 9.4.9-0+deb8u1 [164 kB]
Get:7 http://httpredir.debian.org/debian/ jessie/main libpq5 amd64 9.4.9-0+deb8u1 [124 kB]
Get:8 http://httpredir.debian.org/debian/ jessie/main logrotate amd64 3.8.7-1+b1 [52.2 kB]
Get:9 http://httpredir.debian.org/debian/ jessie/main exim4-config all 4.84.2-2+deb8u1 [503 kB]
Get:10 http://httpredir.debian.org/debian/ jessie/main exim4-base amd64 4.84.2-2+deb8u1 [1049 kB]
Get:11 http://httpredir.debian.org/debian/ jessie/main exim4-daemon-light amd64 4.84.2-2+deb8u1 [632 kB]
Get:12 http://httpredir.debian.org/debian/ jessie/main bsd-mailx amd64 8.1.2-0.20141216cvs-2 [81.7 kB]
Get:13 http://httpredir.debian.org/debian/ jessie/main exim4 all 4.84.2-2+deb8u1 [8544 B]
Get:14 http://httpredir.debian.org/debian/ jessie/main locales all 2.19-18+deb8u6 [3945 kB]
Get:15 http://httpredir.debian.org/debian/ jessie/main lsb-release all 4.1+Debian13+nmu1 [26.5 kB]
Get:16 http://httpredir.debian.org/debian/ jessie/main postgresql-client-common all 165+deb8u1 [73.7 kB]
Get:17 http://httpredir.debian.org/debian/ jessie/main postgresql-client-9.4 amd64 9.4.9-0+deb8u1 [1079 kB]
Get:18 http://httpredir.debian.org/debian/ jessie/main ssl-cert all 1.0.35 [20.9 kB]
Get:19 http://httpredir.debian.org/debian/ jessie/main postgresql-common all 165+deb8u1 [203 kB]
Get:20 http://httpredir.debian.org/debian/ jessie/main postgresql-9.4 amd64 9.4.9-0+deb8u1 [3697 kB]
Get:21 http://httpredir.debian.org/debian/ jessie/main postgresql all 9.4+165+deb8u1 [52.1 kB]
Get:22 http://httpredir.debian.org/debian/ jessie/main psmisc amd64 22.21-2 [119 kB]
�[91mdebconf: delaying package configuration, since apt-utils is not installed
�[0mFetched 12.0 MB in 49s (241 kB/s)
Selecting previously unselected package init-system-helpers.
(Reading database ... 100%
(Reading database ... 21091 files and directories currently installed.)
Preparing to unpack .../init-system-helpers_1.22_all.deb ...
Unpacking init-system-helpers (1.22) ...
Selecting previously unselected package cron.
Preparing to unpack .../cron_3.0pl1-127+deb8u1_amd64.deb ...
Unpacking cron (3.0pl1-127+deb8u1) ...
Selecting previously unselected package libpopt0:amd64.
Preparing to unpack .../libpopt0_1.16-10_amd64.deb ...
Unpacking libpopt0:amd64 (1.16-10) ...
Selecting previously unselected package liblockfile-bin.
Preparing to unpack .../liblockfile-bin_1.09-6_amd64.deb ...
Unpacking liblockfile-bin (1.09-6) ...
Selecting previously unselected package liblockfile1:amd64.
Preparing to unpack .../liblockfile1_1.09-6_amd64.deb ...
Unpacking liblockfile1:amd64 (1.09-6) ...
Preparing to unpack .../libpq-dev_9.4.9-0+deb8u1_amd64.deb ...
Unpacking libpq-dev (9.4.9-0+deb8u1) over (9.4.6-0+deb8u1) ...
Preparing to unpack .../libpq5_9.4.9-0+deb8u1_amd64.deb ...
Unpacking libpq5:amd64 (9.4.9-0+deb8u1) over (9.4.6-0+deb8u1) ...
Selecting previously unselected package logrotate.
Preparing to unpack .../logrotate_3.8.7-1+b1_amd64.deb ...
Unpacking logrotate (3.8.7-1+b1) ...
Selecting previously unselected package exim4-config.
Preparing to unpack .../exim4-config_4.84.2-2+deb8u1_all.deb ...
Unpacking exim4-config (4.84.2-2+deb8u1) ...
Selecting previously unselected package exim4-base.
Preparing to unpack .../exim4-base_4.84.2-2+deb8u1_amd64.deb ...
Unpacking exim4-base (4.84.2-2+deb8u1) ...
Selecting previously unselected package exim4-daemon-light.
Preparing to unpack .../exim4-daemon-light_4.84.2-2+deb8u1_amd64.deb ...
Unpacking exim4-daemon-light (4.84.2-2+deb8u1) ...
Selecting previously unselected package bsd-mailx.
Preparing to unpack .../bsd-mailx_8.1.2-0.20141216cvs-2_amd64.deb ...
Unpacking bsd-mailx (8.1.2-0.20141216cvs-2) ...
Selecting previously unselected package exim4.
Preparing to unpack .../exim4_4.84.2-2+deb8u1_all.deb ...
Unpacking exim4 (4.84.2-2+deb8u1) ...
Selecting previously unselected package locales.
Preparing to unpack .../locales_2.19-18+deb8u6_all.deb ...
Unpacking locales (2.19-18+deb8u6) ...
Selecting previously unselected package lsb-release.
Preparing to unpack .../lsb-release_4.1+Debian13+nmu1_all.deb ...
Unpacking lsb-release (4.1+Debian13+nmu1) ...
Selecting previously unselected package postgresql-client-common.
Preparing to unpack .../postgresql-client-common_165+deb8u1_all.deb ...
Unpacking postgresql-client-common (165+deb8u1) ...
Selecting previously unselected package postgresql-client-9.4.
Preparing to unpack .../postgresql-client-9.4_9.4.9-0+deb8u1_amd64.deb ...
Unpacking postgresql-client-9.4 (9.4.9-0+deb8u1) ...
Selecting previously unselected package ssl-cert.
Preparing to unpack .../ssl-cert_1.0.35_all.deb ...
Unpacking ssl-cert (1.0.35) ...
Selecting previously unselected package postgresql-common.
Preparing to unpack .../postgresql-common_165+deb8u1_all.deb ...
Adding 'diversion of /usr/bin/pg_config to /usr/bin/pg_config.libpq-dev by postgresql-common'
Unpacking postgresql-common (165+deb8u1) ...
Selecting previously unselected package postgresql-9.4.
Preparing to unpack .../postgresql-9.4_9.4.9-0+deb8u1_amd64.deb ...
Unpacking postgresql-9.4 (9.4.9-0+deb8u1) ...
Selecting previously unselected package postgresql.
Preparing to unpack .../postgresql_9.4+165+deb8u1_all.deb ...
Unpacking postgresql (9.4+165+deb8u1) ...
Selecting previously unselected package psmisc.
Preparing to unpack .../psmisc_22.21-2_amd64.deb ...
Unpacking psmisc (22.21-2) ...
Processing triggers for systemd (215-17+deb8u4) ...
Setting up init-system-helpers (1.22) ...
Setting up cron (3.0pl1-127+deb8u1) ...
Adding group `crontab' (GID 108) ...
Done.
update-rc.d: warning: start and stop actions are no longer supported; falling back to defaults
invoke-rc.d: policy-rc.d denied execution of start.
Setting up libpopt0:amd64 (1.16-10) ...
Setting up liblockfile-bin (1.09-6) ...
Setting up liblockfile1:amd64 (1.09-6) ...
Setting up libpq5:amd64 (9.4.9-0+deb8u1) ...
Setting up libpq-dev (9.4.9-0+deb8u1) ...
Setting up logrotate (3.8.7-1+b1) ...
Setting up exim4-config (4.84.2-2+deb8u1) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
Adding system-user for exim (v4)
Setting up exim4-base (4.84.2-2+deb8u1) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
exim: DB upgrade, deleting hints-db
Setting up exim4-daemon-light (4.84.2-2+deb8u1) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
invoke-rc.d: policy-rc.d denied execution of start.
Setting up bsd-mailx (8.1.2-0.20141216cvs-2) ...
update-alternatives: using /usr/bin/bsd-mailx to provide /usr/bin/mailx (mailx) in auto mode
Setting up exim4 (4.84.2-2+deb8u1) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
Setting up locales (2.19-18+deb8u6) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
Generating locales (this might take a while)...
Generation complete.
Setting up lsb-release (4.1+Debian13+nmu1) ...
Setting up postgresql-client-common (165+deb8u1) ...
Setting up postgresql-client-9.4 (9.4.9-0+deb8u1) ...
update-alternatives: using /usr/share/postgresql/9.4/man/man1/psql.1.gz to provide /usr/share/man/man1/psql.1.gz (psql.1.gz) in auto mode
Setting up ssl-cert (1.0.35) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
Setting up postgresql-common (165+deb8u1) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
Adding user postgres to group ssl-cert

Creating config file /etc/postgresql-common/createcluster.conf with new version

Creating config file /etc/logrotate.d/postgresql-common with new version
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
Removing obsolete dictionary files:
invoke-rc.d: policy-rc.d denied execution of start.
Setting up postgresql-9.4 (9.4.9-0+deb8u1) ...
Creating new cluster 9.4/main ...
  config /etc/postgresql/9.4/main
  data   /var/lib/postgresql/9.4/main
  locale C
  port   5432
update-alternatives: using /usr/share/postgresql/9.4/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode
invoke-rc.d: policy-rc.d denied execution of start.
Setting up postgresql (9.4+165+deb8u1) ...
Setting up psmisc (22.21-2) ...
Processing triggers for systemd (215-17+deb8u4) ...
Processing triggers for libc-bin (2.19-18+deb8u4) ...
 ---> ec3ccaec4bf5
Removing intermediate container 9e74bd9a0915
Successfully built ec3ccaec4bf5
#+end_example

@parserpro
Copy link

parserpro commented Nov 15, 2016

Hi!
I also have a similar problem. My Dockerfile:

FROM perl:5.24

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get -qq update
RUN apt-get install apt-utils -y
RUN apt-get install dialog -y
RUN apt-get install whiptail -y
RUN apt-get install libgd2-xpm-dev -y
RUN apt-get install libdbd-mysql-perl -y
RUN apt-get install zip -y
RUN apt-get install unzip -y
RUN apt-get install mc -y
RUN apt-get install libmysqlclient18 -y
RUN apt-get install libmysqlclient-dev -y
RUN rm -rf /var/lib/apt/lists/*

RUN curl -L http://cpanmin.us | perl - App::cpanminus

RUN ln -s /usr/include/x86_64-linux-gnu/ImageMagick-6/ /usr/local/include/ImageMagick-6
&& ln -s /usr/local/lib/perl5/5.24.0/x86_64-linux/CORE/libperl.so /usr/local/lib/libperl.so
&& cpanm --notest Image::Magick

RUN cpanm [email protected]
RUN cpanm Test::UNIXSock
RUN cpanm Term::ProgressBar
RUN cpanm common::sense
...

All Perl modules are installed into system perl 5.20.2, not into 5.24.
Really don't know what to do?

@zakame
Copy link
Member

zakame commented Aug 2, 2017

Hi all, sorry for the late reply to this issue; I'm looking at what options to resolve this.

On one hand, @pergh has a point that there is a system perl in /usr/bin that is introduced by our use of buildpack-deps as a base image, so one option may be to build out our own base image that uses the upstream Perl exclusively.

On the other hand, switching base images might be too expensive (e.g. it would introduce new layers into the image history, I think,) so maybe another option (and perhaps simpler) is to document how to install CPAN modules clearly (and what to do wrt dependencies on system-installed packages such as dev headers to database modules.)

I'm leaning toward the latter option for now and will try to push another doc update.

@KES777
Copy link

KES777 commented May 7, 2018

@parserpro
To change directory where perl modules are install you should play with next environment variables:

PERL_MB_OPT=--install_base "/home/feelsafe/perl5"
PERL_MM_OPT=INSTALL_BASE=/home/feelsafe/perl5
PERL_LOCAL_LIB_ROOT=/home/feelsafe/perl5
PERL5LIB=/home/feelsafe/perl5/lib/perl5

Or use perlbrew

@AnthonyMastrean
Copy link

AnthonyMastrean commented Sep 10, 2018

We're using perl:5-slim and trying to get the SNMP module via the Debian package libsnmp-perl. We understand this to be the "correct" way to install this module. However, it's installing into the Perl 5.24 that comes with Debian.

root@b44dc55652c8:/app# find / -name SNMP.pm
/usr/lib/x86_64-linux-gnu/perl5/5.24/SNMP.pm

Am I correct that this is an example of the problem described in this ticket?


In the meantime, we can't quite find the right combination of ENV vars to fix the installation into the Perl 5.28 that's installed by this base image.

ENV PERL5LIB /usr/local/lib/perl5/5.28.0

Maybe our problem is the way this specific package manages deps? If so, I'll take my comment out of this thread 😄

root@b44dc55652c8:~# dpkg -I /var/cache/apt/archives/libsnmp-perl_5.7.3+dfsg-1.7_amd64.deb
...
Depends: perl (>= 5.24.1-1), perlapi-5.24.1, libc6 (>= 2.15), libsnmp30 (>= 5.7.3+dfsg-1.7~dfsg)

We’re having better luck using the debian:stretch-slim image directly. System package installed Perl plus other system packages... we’re OK with Perl 5.24 in this case.

@KES777
Copy link

KES777 commented Sep 10, 2018

@AnthonyMastrean :
You can not set only some of them and must setup all:

PERL_MB_OPT=--install_base "/usr/local/lib/perl5/5.28.0"
PERL_MM_OPT=INSTALL_BASE=/usr/local/lib/perl5/5.28.0

because different modules uses as installer makemaker or makebuild we are required to manage both env variables.

These two variables

PERL_LOCAL_LIB_ROOT=/usr/local/lib/perl5/5.28.0
PERL5LIB=/usr/local/lib/perl5/5.28.0

are just used to instruct perl where to look to find required modules. So if you even setup PERL_M* correct but do not configure *LIB* variables. Your perl just do not notice installed modules.

Thus use those four variables or perlbrew

To my mind usage of perlbrew is super easy. Also it is light weight.

@zakame
Copy link
Member

zakame commented Sep 10, 2018

Hi @AnthonyMastrean!

I think that if you wish to install Net-SNMP into Perl v5.28 in perl:5-slim, it might be preferable to install it from source, instead of from the Debian package, as the Debian package is already prebuilt to install on Debian Perl 5.24 paths.

@zakame
Copy link
Member

zakame commented Jul 27, 2019

So to recap, this issue can be resolved by

  • ensuring use /usr/local/bin/perl provided by our Perl images here
  • installing Perl modules from CPAN or other sources, rather than via Debian packages
  • using EUMM/MB variables to install modules on different paths if necessary

I'll close this issue as it is old now; feel free to open a new issue and reference this if needed later. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants