local::libs for Dist Development

Most of my distributions are on GitHub and built using Dist::Zilla. As the dependencies of each vary widely and I don’t want to muck up my workstation’s libraries, I set up a local::lib for each distribution’s development.

The App::local::lib::helper scripts make this really easy. As per the docs, I combine the helper with App::cpanminus (cpanm) for all installation.

To bootstrap a new local::lib area, I wrote this simple shell script:

#!/bin/bash
# script named "new-ll"

if [ -z $1 ]
  then
    echo 'pass the distribution name, please'
    exit
fi

echo "creating local::lib for $1 ..."
sleep 3

curl -L http://cpanmin.us/ | perl - --notest --quiet --local-lib \
    ~/perl5/$1 \
    App::cpanminus \
    Dist::Zilla \
    App::local::lib::helper

.
Entering the correct environment for a distribution uses another helper script:

#!/bin/bash
# script named "go"

if [ -z $1 ]
  then
    echo 'pass the distribution name, please'
    exit
fi

~/perl5/$1/bin/localenv bash

.
Which means my workflow for a new distribution is:

$ new-ll New-Dist-Name
$ go New-Dist-Name

.
Any Perl distributions installed in that shell (for example from dzil authordeps | cpanm or dzil listdeps | cpanm) will be placed into the new local::lib. It’s a simple ^D to exit.

However it’s not obvious that you’re within this special environment, so editing Bash’s $PS1 variable (the shell prompt) to include the following, can help:

echo $PERL5LIB | cut -d'/' -f5

.
My deep thanks to the authors of the distributions used to create this neat setup.

1 Comment

Leave a comment

About Oliver Gorwits

user-pic Computer Networks is my business, so Perl is my glue.