How to build DBD::mysql with DBI in a custom @INC?

I’m building DBI and DBD::mysql in a continuous integration build server. The build of DBI is successful, as seen in the excerpt of the build log below. It clearly installs DBI/DBD.pm in the correct location.

pushd DBI-1.643

perl Makefile.PL INSTALL_BASE=/data/pods/mysql-tools/mysql-tools/current

...
Installing /data/pods/mysql-tools/mysql-tools/current/lib/perl5/x86_64-linux-thread-multi/DBI/DBD.pm
...
Appending installation info to /data/pods/mysql-tools/mysql-tools/current/lib/perl5/x86_64-linux-thread-multi/perllocal.pod

But the next part of the build for DBD::mysql fails because it can’t find the files installed by DBI.

pushd DBD-mysql-4.050

perl Makefile.PL INSTALL_BASE=/data/pods/mysql-tools/mysql-tools/current --ssl

Can't locate DBI/DBD.pm in @INC (@INC contains:
/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 Makefile.PL line 15.

You can see, MakeMaker for DBD::mysql isn’t adding the install location to its @INC at all. It just has default directories.

Is there a way to pass an argument to MakeMaker to add the install directory to @INC? I suppose I could hard-code it, but that seems improper and hard to maintain. Is there a better way to automatically add INSTALL_BASE/lib/perl5/<arch> to @INC?

Environment:

  • CentOS 7 Linux
  • Perl 5.16.3

I would have preferred to use cpanm of course. But the CI build server is isolated from the internet because of my employer’s security policy. No http proxying is allowed from CI.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

According to the documentation, INSTALL_BASE is used for telling make install where to put the installed module:

INSTALL_BASE

INSTALL_BASE can be passed into Makefile.PL to change where your
module will be installed. INSTALL_BASE is more like what everyone else
calls “prefix” than PREFIX is.

but it does not tell perl where to look for installed modules. To do that you can use the environment variable PERL5LIB, according to the documentation :

PERL5LIB

A list of directories in which to look for Perl library files before
looking in the standard library. Any architecture-specific and
version-specific directories, such as version/archname/, version/, or
archname/ under the specified locations are automatically included if
they exist, with this lookup done at interpreter startup time. In
addition, any directories matching the entries in
$Config{inc_version_list} are added.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x