Fix OpenCA start error Can’t locate version.pm

Updated on February 22, 2018

Well, I got an error “install_driver(Pg) failed: Can’t locate version.pm” while starting OpenCA 1.5.1 daemon on CentOS. This tutorial will explain how to fix OpenCA start error Can’t locate version.pm. Before I talk about the solution, have a look at the complete error message.

Starting OpenCA daemon:

# ./etc/init.d/openca start

Though the above command didn’t throw any message, I could find a detailed error in var/openca/log/stderr.log. Below is the snapshot of it.

install_driver(Pg) failed: Can't locate version.pm in @INC (@INC contains: /home/openca/lib/openca/perl_modules/perl5/x86_64-linux-thread-multi /home/openca/lib/openca/perl_modules/perl5 /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /home/openca/lib/openca/perl_modules/perl5/x86_64-linux-thread-multi/DBD/Pg.pm line 19.
BEGIN failed--compilation aborted at /home/openca/lib/openca/perl_modules/perl5/x86_64-linux-thread-multi/DBD/Pg.pm line 19.
Compilation failed in require at (eval 288) line 3.
Perhaps a module that DBD::Pg requires hasn't been fully installed
 at /home/openca/lib/openca/perl_modules/perl5/OpenCA/DBI.pm line 914.
Compilation failed in require at /home/openca/etc/openca/openca_start line 66.

The error message indicates that it couldn’t locate version.pm file and perhaps a module that DBD::Pg has not been installed fully. Let’s install DBD::Pg.

Install DBD::Pg using cpan

cpan[1]> install DBD::Pg

However, cpan failed installing DBD::Pg and exited with the below error message.

Could not load DBI::DBD - is the DBI module installed?
No 'Makefile' created'YAML' not installed, will not store persistent state
 TURNSTEP/DBD-Pg-3.7.4.tar.gz
 /usr/bin/perl Makefile.PL -- NOT OK
Running make test
 Make had some problems, won't test
Running make install
 Make had some problems, won't install
Could not read metadata file. Falling back to other methods to determine prerequisites
Failed during this command:
 TURNSTEP/DBD-Pg-3.7.4.tar.gz : writemakefile NO -- No 'Makefile' created

So I had install DBI::DBD module before installing DBD::Pg. Let’s go ahead and install DBI::DBD

Install DBI::DBD

cpan> install DBI::DBD

Appending installation info to /usr/lib64/perl5/perllocal.pod
 TIMB/DBI-1.640.tar.gz
 /usr/bin/make install -- OK

Yes, I have now installed DBI::DBD module, let’s retry DBD::Pg installation via cpan.

cpan> install DBD::Pg

Ah! another error:

cp lib/Bundle/DBD/Pg.pm blib/lib/Bundle/DBD/Pg.pm
cp Pg.pm blib/lib/DBD/Pg.pm
/usr/bin/perl -p -e "s/~DRIVER~/Pg/g; s/^do\(/dontdo\(/" /usr/local/lib64/perl5/auto/DBI/Driver.xst > Pg.xsi
/usr/bin/perl /usr/share/perl5/vendor_perl/ExtUtils/xsubpp -typemap /usr/share/perl5/ExtUtils/typemap Pg.xs > Pg.xsc && mv Pg.xsc Pg.c
gcc -c -I/usr/include -I/usr/local/lib64/perl5/auto/DBI -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPGLIBVERSION=90223 -DPGDEFPORT=5432 -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc -Dcalloc=Perl_calloc -DVERSION=\"undef\" -DXS_VERSION=\"undef\" -fPIC "-I/usr/lib64/perl5/CORE" Pg.c
In file included from Pg.xs:14:0:
Pg.h:36:22: fatal error: libpq-fe.h: No such file or directory
 #include "libpq-fe.h"
 ^
compilation terminated.
make: *** [Pg.o] Error 1
 TURNSTEP/DBD-Pg-3.7.4.tar.gz
 /usr/bin/make -- NOT OK
Running make test
 Can't test without successful make
Running make install
 Make had returned bad status, install seems impossible
Failed during this command:
 TURNSTEP/DBD-Pg-3.7.4.tar.gz : make NO

Now the error is “fatal error: libpq-fe.h: No such file or directory“. It means, I had to install a package or library that ships libpq-fe.h file. After googling, I understand ‘libpg-dev‘ is the library, but that’s for Ubuntu and Debian machines. So the corresponding package for CentOS is ‘postgresql-devel‘.

Install postgresql-devel using YUM

# yum install postgresql-devel
:::::::::::::::::
Installed:
 postgresql-devel.x86_64 0:9.2.23-3.el7_4

Complete!

Ok. Hopefully, cpan should now install DBD::Pg without any problem. Let’s check it out.

Installing DBD::Pg again using cpan

cpan[3]> install DBD::Pg
Running install for module 'DBD::Pg'
Running make for T/TU/TURNSTEP/DBD-Pg-3.7.4.tar.gz
 Has already been unwrapped into directory /root/.cpan/build/DBD-Pg-3.7.4-JtTHAe
Could not make: Unknown error
Running make test
 Can't test without successful make
Running make install
 Make had returned bad status, install seems impossible

What! cpan says install seems impossible? Nope, let’s install it manually. To do that, I had to go to .cpan directory located under user’s home and locate DBD-PG downloaded by cpan.

# cd /root/.cpan/build/DBD-Pg-3.7.4-ScxNAT

Let’s create Makefile now.

# perl Makefile.PL
Configuring DBD::Pg 3.7.4
PostgreSQL version: 90223 (default port: 5432)
POSTGRES_HOME: (not set)
POSTGRES_INCLUDE: /usr/include
POSTGRES_LIB: /usr/lib64
OS: linux
Checking if your kit is complete...
Looks good
Using DBI 1.64 (for perl 5.016003 on x86_64-linux-thread-multi) installed in /usr/local/lib64/perl5/auto/DBI/
Writing Makefile for DBD::Pg

Cool. What about make?

#make
chmod 755 blib/arch/auto/DBD/Pg/Pg.so
cp Pg.bs blib/arch/auto/DBD/Pg/Pg.bs
chmod 644 blib/arch/auto/DBD/Pg/Pg.bs
Manifying blib/man3/Bundle::DBD::Pg.3pm
Manifying blib/man3/DBD::Pg.3pm

Cool again, what about install?

# make install
Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
Installing /usr/local/lib64/perl5/auto/DBD/Pg/Pg.so
Installing /usr/local/lib64/perl5/auto/DBD/Pg/Pg.bs
Installing /usr/local/lib64/perl5/DBD/Pg.pm
Installing /usr/local/lib64/perl5/Bundle/DBD/Pg.pm
Installing /usr/local/share/man/man3/Bundle::DBD::Pg.3pm
Installing /usr/local/share/man/man3/DBD::Pg.3pm
Appending installation info to /usr/lib64/perl5/perllocal.pod

Yes. I have now successfully installed “DBD::Pg” module. Now I started OpenCA daemon and it worked without any fuss.

Hope it helps someone out there.

Was this article helpful?

Related Articles

Leave a Comment