Setting up Perl's `local::lib` for LedgerSMB: why and how?

Submitted by ehu on

Introducing to local::lib

Straight from local::lib's RATIONALE section:


The version of a Perl package on your machine is not always the version you need. [...]

local::lib solves this problem by allowing you to create your own directory of Perl packages downloaded from CPAN (in a multi-user system, this would typically be within your own home directory). The existing system Perl installation is not affected; you simply invoke Perl with special options so that Perl uses the packages in your own local package directory rather than the system packages. local::lib arranges things so that your locally installed version of the Perl packages takes precedence over the system installation.

If you are using a package management system (such as Debian), you don't need to worry about Debian and CPAN stepping on each other's toes. Your local version of the packages will be written to an entirely separate directory from those installed by Debian.

To achieve its goal by setting specific values for standard (Perl) environment variables:

    Perl's search path for Perl modules (*.pm files)
  • PATH
    the shell's search path for executables (including CPAN installed "utilities")
    options for Module::Build and MakeMaker respectively, used when installing modules from CPAN

Why use local::lib with LedgerSMB?

LedgerSMB is - measured in terms of functionality - large application. In order to perform some of its functions, LedgerSMB needs to execute actions for which code has been developed and uploaded to CPAN by other projects. As the LedgerSMB development team would rather concentrate on its core responsibilities, the philosophy is to outsource as much of its code as can be outsourced to reliable other projects in the Perl community. (Code re-use before writing its own code.) As a result, LedgerSMB's list of direct and indirect dependencies is quite impressive.

With the list of dependencies, the chances increase of dependencies of LedgerSMB requiring incompatible minimum and/or maximum versions of libraries which are already installed on your system. Preventing these conflicts from becoming a problem is exactly the use-case for local::lib.

Installing local::lib