He does strike a nerve there. Ever since Gugod's amazing perlbrew came to life, installing your custom perl - or several perls for that matter - is *really* easy. However, a new problem surfaced: updating your installation so your applications work again. This is, of course, per design. After all, perlbrew is supposed to give you completely separate installations, and this includes installed modules.
So, what can you do? Copying your lib directory is out of the question if you have any module that does XS, and chances are you probably do. I'm also not sure if an external local::lib directory would play nice either.
Luckily, there's a quick-and-dirty recipe to migrate your installed modules from one perlbrew installation to another. Say I just upgraded from 5.14.2 to 5.16.0 and want to install the same modules I had before:
$ perlbrew switch 5.14.2
$ perl -MExtUtils::Installed -E 'say for ExtUtils::Installed->new->modules' > /tmp/installed.list
$ perlbrew switch perl-5.16.0
$ perlbrew install-cpanm
$ cat /tmp/installed.list | cpanm --interactive
Done!
What I did there was use the core module ExtUtils::Installed to create a list of installed modules in the file "/tmp/installed.list", then feed that list to cpanm. I used "--interactive" because some modules I have (like SDL) ask a few questions during installation, but whatever rocks your boat.
Also worth noticing that depending on the amount of modules you have installed, that last step can take quite a while, so go watch a movie, read a book or something :)
I think this tip is particularly pertinent if you're trying out a Release Candidate (RC) for a future perl release and want to make sure your toolchain builds properly - which is always a good idea.
I'm going to bug gugod for a bit to see if we can come up with something bundled into perlbrew to make this even easier, but for now you can use this :)
Hope it helps! Happy Perl Brewing!
miyagawa posted a gist for a migration script, which i modified slightly. it worked pretty well for migrating my installed cpan modules: https://gist.github.com/2772279
ReplyDeleteNice tip, Ben! That's even easier =)
ReplyDeleteBTW, I've made a "cpan-tested" script which verifies CPAN Testers status for a piped list of modules: https://gist.github.com/2772279
ReplyDeleteGeez, I'm so embarrassed by the lack of my copy/paste skills...
DeleteThe correct link: https://gist.github.com/1712854
Didn't Miyagawa also write carton, perl's answer to ruby's Bundler gem?
ReplyDeleteHe does. There was a presentation from Perl Mova... (which I can't find right now)
DeleteYay! Now put in inside perlbrew so it can be done in one step.
ReplyDeleteWell, two steps:
ReplyDelete'perlbrew save-installed-modules' does 'step 2' of the list, and 'perlbrew install-saved-modules' to do 'step 5' of the list... at least, that'd be the way I'd implement it.
I'll have to send this to myself at home and see if I can write a patch still.