perlbrew fails with “Can't locate Devel/PatchPerl.pm”

只愿长相守 提交于 2019-12-06 03:00:58

Upgrade perlbrew (perlbrew self-upgrade or the shell bootstrap incantation from http://perlbrew.pl/).

Recent versions install patchperl into $PERLBREW_ROOT/bin through perlbrew install-patchperl.

Can someone explain why perlbrew does this?

Devel::PatchPerl is found inside of patchperl. perlbrew surely clears those vars so you don't accidentally find the wrong modules (as it would have for you if perlbrew hadn't cleared those).

Something wrong if your install of perlbrew if patchperl can't find code that's suppose to be present in patchperl itself! Reinstall it from scratch.

I ran into this after trying a fresh (only) install of perlbrew, after installing local::lib. When installing perlbrew via CPAN (not the only way, I've used curl -kL http://install.perlbrew.pl | bash before, with local::lib disabled), the Devel::PatchPerl module was properly installed into ~/perl5/lib/perl5, but as we both found out, perlbrew won't look there. Running perlbrew install-patchperl installs a standalone version of patchperl — built with App::FatPacker — into ~/perl5/perlbrew/bin.

This allows me to have a local "system" perl, with customized libraries and tools provided by local::lib, for ordinary and experimental work. But I can switch to using a perlbrew'ed perl for special projects or applications, for an even more controlled environment. The real system perl is almost never modified.

Caveat - when local::lib is enabled by default in your .bashrc, a simple perlbrew use perl-5.18.2 does NOT remove the local:lib-specific environment varialbles (PERL_MM_OPT and PERL_MM_OPT - you must do it yourself. One (somewhat cumbersome, but simple) trick is:

perlbrew lib create perl-5.18.2@none  # do this once after brewing a perl
perlbrew use perl-5.18.2@none
perlbrew use perl-5.18.2

This also means, that to switch off perlbrew, you can do this:

perlbrew off
eval $(perl -Mlocal::lib | grep -v PERL_LOCAL_LIB_ROOT)

And you are back to your default local::lib setup. Though better to close and reopen a new shell, to avoid extending your $PATH ad infinitum.

This is the simplest way I have found so far to get independent, custom perl environments, including the system perl with your default (local::lib) customizations.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!