Using Perlbrew on Ubuntu
Today I discovered that I was using Perl 5, version 14.2 (v5.14.2) from the Ubuntu 12.04 packages. It includes 57 registered patches. As it is a 2011 version, I’ve decided to switch from the Ubuntu packages to a more recent one (and considered as stable by the Perl community although it is not by the Debian one).
As I love to use local::lib and cpanm, I’ve chosen to use Perlbrew to achieve the installation of this last stable version. The tool seems as convenient as cpanm and local::lib, it is known for making your life easier when dealing with Perl installations.
Perlbrew is :
- a tool to install different versions of perls and switch through them
- an admin-free installation management system, means, as for
local::lib, you don’t even need to have superuser rights to use it, so you don’t have to suck the admin’s ass - it’s just like
RVMfor those who know Ruby
The reason I write this post is that I encountered a tiny problem when installing Perlbrew on an Ubuntu box, so I hope it could be useful for you.
I assume that you already have cpanm and local::lib installed (you don’t use the root account nor sudo).
1
| |
1 2 3 4 5 6 7 8 9 10 11 12 | |
`
It has created some files in ~/.perlbrew. You need to add the one that fit your environment in your configuration file (.bashrc or other) :
1
| |
Now start a new shell or source your shell configuration file, that’s it Perlbrew is on! You can check which Perls are available :
1 2 3 4 5 6 7 8 9 10 11 12 | |
So pick a version, or ask for the last stable one. In fact, that’s the moment I encountered an issue with Perlbrew and Devel::PatchPerl.pm. I asked for last stable Perl’s installation but it failed :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | |
As the process was failing, I tailed the logs :
1 2 3 4 5 6 7 | |
I tried to update a Devel::PatchPerl, but updating stupidely without understanding or without reading the doc is useless. Finally, I found the answer on StackOverflow, even if it was clearly mentioned in the Perlbrew logs, you should better read sentences till the end and do what you’re told. Perlbrew seems to embark its own Devel::PatchPerl in ~/perl5/perlbrew/bin, and you should not use the core one. More about this on Perlbrew website… So now do what you’re told :
1
| |
Ok, it seems everything is ok. I tried some perl -v and the version has changed. But when installing Dancer with cpanm and setup a test Dancer application, Dancer was reconizing the old version :

That’s because, in the same spirit when need a dedicated patchperl, the cpanm installation need a special process too :
1 2 3 4 5 | |
This fixes the issues, the environment is ready. I believe all previously installed modules through cpanm should be re-installed now.
Perls installations will be very very easy to achieve :
1 2 | |
Happy brewing !
References
- perlbrew.pl/
- Perlbrew on MetaCPAN
- A talk about Perlbrew by Kang-min Liu