Fork me on github!!

Perlbrew and Friends

If you install perlbrew with the installer as recommended, you might notice that an executable named patchperl is also installed to your ~/perl5/perlbrew/bin directory. Also when you read the perlbrew usage documentation, there is a command install-cpanm that installs a standalone executable cpanm to to the same bin directory. Why is perlbrew doing this ?

The program patchperl is a standalone executable of the distribution of Devel::PatchPerl by BINGOS, which aims to solve the issues encountered when building old perls (5.6.x, 5.8.x, etc) on modern operating systems. Due to the updates in OS, gcc, or libc, those old perl distributions fail to build due to various configure or library errors. Devel::PatchPerl patches the ancient perl source tree so it can be successfully built.

perlbrew requires the patchperl program to be there because it is the best way to make it Just Work. cpanm is an awesome CPAN client that is lightweight, and fast. I use it exclusively these days.

The reason that these programs live under ~/perl5/perlbrew/bin is very simple: so they are always available no matter which perl you switch to.

With a proper perlbrew setup, ~/perl5/perlbrew/bin should be the first or second item in your $PATH, since perlbrew switch and perlbrew use alters $PATH, it is the best that mandatory programs lives somewhere that's always accessible.

If you install cpanm by doing cpan -i App::cpanminus within a perlbrew environment, you will run into this issue:

perlbrew switch perl-5.12.3
cpan -i App::cpanminus
cpanm Moose # works

perlbrew switch perl-5.14.0
cpanm Moose
#=> cpanm is not found 

This is because the first cpan (5.12.3) installs cpanm to ~/perl5/perlbrew/perls/5.12.3/bin, and the latter perlbrew switch perl-5.14.0 removes that from $PATH. If you use cpanm exclusively like I do, you should install it with perlbrew install-cpanm.

In short, patchperl and cpanm are so important, it is best to make them always available.

peace out, gugod.

PS. You may also choose to manually install cpanm to a system-wide path like /usr/local/bin, that way it'll always available too. In that case you do not need to run perlbrew install-cpanm command at all.