Friday, July 2, 2010

App::perlbrew - Manage perl installations in your $HOME or wherever you want

Prerequisites:
  • $ zypper install patch
  • $ zypper install gcc
Caveat:
  • yes, "perlbrew install" occasionally and too often  needs "--force" and even "--notest", don't be too surprised! my "5.14.2" and also my "5.16.1" needed it

Main links:

$ export PERLBREW_ROOT=/opt/perlbrew
$ curl -kL http://install.perlbrew.pl | bash
# or maybe like this:
$ perlbrew self-upgrade


The developer/maintainer does not have in mind this use case as the main use case!! But it is my main use case.
What to do after installing a new perl, that you consider your new stable perl?
$ perlbrew alias create perl-RELEASE stable 
# resp.
$ perlbrew alias -f create perl-RELEASE stable
# use this shebang line with $PERLBREW_ROOT expanded [Link]:
#! $PERLBREW_ROOT/perls/stable/bin/perl

$ perlbrew switch stable # this will be our usual starting point!!!
 
# but "perlbrew list-modules" does not work on such an alias, so "perlbrew use" to a non-alias before!


  • Have a serious look at "$ perlbrew help" once in a while!!!



I decided to make use of $PERLBREW_ROOT, as I want to keep my home $HOME minimial, just data and scripts, no big files, they all go to other disks. And right, my home directory is on an encrypted partition, and this sort of stuff certainly does not get encrypted.
$ export PERLBREW_ROOT=/usr/local/perlbrew
Therefore my perlbrew is installed as:
/usr/local/perlbrew/bin/perlbrew
They suggest, that my $HOME/.bashrc should "source" their .../etc/bashrc, but for the time being I let my $HOME/.profile do this, as IMHO this is right place.
So actually this is according to best practices for shell programming the right way (for me) to do it, and now this code is of course included in my $HOME/.profile:


# for perl's App::perlbrew :
export          PERLBREW_ROOT=/usr/local/perlbrew # on my Linux boxes
export          PERLBREW_ROOT=/sw/perlbrew # on my Mac box(es)
source         $PERLBREW_ROOT/etc/bashrc
##export  PATH=$PERLBREW_ROOT/bin:$PERLBREW_ROOT/perls/current/bin:${PATH}
path_prepend   $PERLBREW_ROOT
path_prepend   $PERLBREW_ROOT/perls/current


BTW: always "$ hash -r" after switching, so you avoid getting certain perl resp. perlbrew related error messages like this one and a few others (confusion of the right installation directory):
bash: …: No such file or directory
I successfully brewed 5.10.1 and 5.12.1 on openSUSE-11.2, but on OS X Snow Leopard I only brewed 5.12.1 successfully, brewing 5.10.1 failed.


To be continued …


Update 2011-10-16:
On my Mac running Lion I was able to perlbrew these releases of perl


  • perl-5.15.3 and
  • perl-5.14.2
  • but not perl-5.12.4, 5.10.1, 5.8.9, 5.6.2

but that seems more than sufficient to me.

Looks like OS X got targeted as a serious platform for perl development only rather recently.


Update 2012-10-07: A historic note: I first looked into perlbrew in the context of "biz-JG".

No comments: