Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I install CPAN modules while using perlbrew?

I have started using perlbrew and installed perl-5.12.2.

I understand I need to re-install my CPAN modules, so I switched to my new Perl version (perlbrew switch perl-5.12.2 and hash -r), verified the switch was successful (perl -v) then tried installing some module (File::Copy::Recursive using cpan. However, cpan says `File::Copy::Recursive is up to date (0.38).

When I start a Perl script using this module, it shouts Can't locate File/Copy/Recursive.pm in @INC ... (showing many perl-5.12.2 locations). When I switch back to my 'normal' Perl (perlbrew off) the script runs fine.

Any suggestions? Perhaps CPAN does not work well with perlbrew?

like image 971
David B Avatar asked Sep 17 '10 07:09

David B


People also ask

How do I install CPAN modules in Strawberry Perl?

Run CPAN client from the Strawberry Perl or Strawberry Perl (64-bit), sub folder Tools, entry in the Start menu. Type install Module::Name there.

How do I install CPAN?

CPAN has evolved and the easiest way now to install CPAN modules is using the CPAN:App::cpanminus installer. It can be run with or without root privileges. (Generally running as root is not recommended.) When run as root it installs into the system libraries.

Where do CPAN modules get installed?

CPAN doesn't actually install files. It runs the install script embedded in each distribution, which then performs the actual install. For distributions using ExtUtils::MakeMaker, the defaults are documented here: https://metacpan.org/pod/ExtUtils::MakeMaker#make-install (and the default value of INSTALLDIRS is site ).


2 Answers

After installing perlbrew you could install cpanm through this command:

perlbrew install-cpanm 

Otherwise you will need to install cpanm manually each time you switch your Perl version on perlbrew. With this command just once.

Once installed you can then use cpanm to install the missing module:

cpanm File::Copy::Recursive 
like image 147
jacktrade Avatar answered Oct 07 '22 19:10

jacktrade


Everything should be working fine with "cpan" as well as "cpanm", that is: when switching perl with perlbrew, cpan sees the installed modules of the version you use.

While it's true that cpanm is the recommended tool to use with perlbrew, cpan allows for test reporting so that is what I always use.

like image 30
arthas Avatar answered Oct 07 '22 19:10

arthas