Module::Build <3 local::lib

If you haven't heard, local::lib is an awesome module that makes it a snap for unprivileged users to set up a local Perl module library. One way it does that it by making it easy to set PERL5LIB and the default installation path for ExtUtils::MakeMaker and Module::Build in your .bashrc or equivalent.

For ExtUtils::MakeMaker, it just sets an environment variable, PERL_MM_OPT. For Module::Build, it currently creates a options file, .modulebuildrc, inside the local perl library and uses an environment variable to make that the default options file.

That's a bit annoying, because it puts the options file in an unexpected place and does so a bit too magically. A user of local::lib might never realize it's there, create their own ~/.modulebuildrc and wonder why it's not working.

So, thanks to a special request from mst, the next release of Module::Build will include support for a new environement variable, PERL_MB_OPT, to make local::lib's job that much easier and with fewer surprises for end users.

This entry was posted in perl programming, toolchain and tagged , . Bookmark the permalink. Both comments and trackbacks are currently closed.


  1. Robert Buels
    Posted October 16, 2009 at 9:43 am | Permalink

    A further downside of the .modulebuildrc that local::lib makes is that the install_base path is hardcoded in there, so if you move that local::lib directory, its .modulebuildrc is no longer correct.

  2. Posted October 16, 2009 at 3:42 pm | Permalink

    I was looking at local::lib a few weeks ago and couldn't quite figure out the advantage to using it over something like this in .bash_profile:

    if [ -d $HOME/lib/perl5 ]; then
    export PERL5LIB

    I'd really like to have a better understanding of when and why to use local::lib and wonder if there are some good examples that folks have to share?


    • dagolden
      Posted October 16, 2009 at 8:37 pm | Permalink

      local::lib sets ExtUtils::MakeMaker and Module::Build to install both Perl modules and programs to a specific directory. That means that you don't have to know the intricacies of configuring or CPANPLUS to do so.

      Further, the incantation for a .bashrc file sets all the environment variables necessary. In your example, you're not getting an architecture specific directory in PERL5LIB.

      Here's an example of what local::lib will do using my "cleanroom" user:

      $ perl -I$HOME/perl5/lib/perl5 -Mlocal::lib
      export MODULEBUILDRC="/home/cleanroom/perl5/.modulebuildrc"
      export PERL_MM_OPT="INSTALL_BASE=/home/cleanroom/perl5"
      export PERL5LIB="/home/cleanroom/perl5/lib/perl5:/home/cleanroom/perl5/lib/perl5/x86_64-linux-gnu-thread-multi:$PERL5LIB"
      export PATH="/home/cleanroom/perl5/bin:$PATH"

      Hope that helps clarify.

      -- David

  3. Posted October 22, 2009 at 7:08 pm | Permalink

    Hey there David,

    Indeed, that helps a lot. I'll give it another spin this weekend. :-)