When I installed perl from the source the first nice surprise was that without doing something all module installed from now on were available to the new perl. Since I didn't find one module on cpan that comes with my OS I have to use for some scripts the onboard-perl. For one of these scripts I would like to install Text::Format or Text::Autoformat (didn't find the docu for that module on cpan). My question: how can I tell cpan to install the module this one time for the OS-distro-perl?
Each Perl installation has its own idea of where libraries should "live", which the CPAN module uses as a guide for where to perform its installations. You can see what these values are by executing perl -V
, and look for the value of @INC
(at the bottom). If you invoke CPAN with a different Perl (e.g. your system-installed Perl), you will automatically install modules into that Perl's preferred location:
/usr/bin/perl -MCPAN -e shell
or to simply install one module without having to invoke the CPAN shell explicitly:
/usr/bin/cpan <modulename>
There are also CPAN configuration options available where you can temporarily or permanently change the install location, but this should not be necessary in your case.
There isn't a special way to tell cpan to install modules in a new location for just the one invocation. That feature, however, is on my to do list, along with local::lib support. I truly understand your pain and want the same feature. I just need the time (or the patch) to make it work.
Until then, you have to enter the CPAN.pm shell and change the values for mbuild_arg
and makefilepl_arg
as noted in perlfaq8: How do I keep my own module directory?:
When you build modules, tell Perl where to install the modules.
For Makefile.PL-based distributions, use the INSTALL_BASE option when generating Makefiles:
perl Makefile.PL INSTALL_BASE=/mydir/perl
You can set this in your CPAN.pm configuration so modules automatically install in your private library directory when you use the CPAN.pm shell:
% cpan
cpan> o conf makepl_arg INSTALL_BASE=/mydir/perl
cpan> o conf commit
For Build.PL-based distributions, use the --install_base option:
perl Build.PL --install_base /mydir/perl
You can configure CPAN.pm to automatically use this option too:
% cpan
cpan> o conf mbuild_arg "--install_base /mydir/perl"
cpan> o conf commit
/path/to/system/perl -MCPAN -e shell
I'm assuming you want to simply install modules to a different location and then run them from that location -- your question wasn't too clear to me.
Read the perldoc fully on local::lib
. It would be a major failure on my part to try to write that better. This is also the most recent and advanced way to achieve this task. If another solution doesn't reference this module, then my personal suggestion would be to avoid it like the plague.
来源:https://stackoverflow.com/questions/2434340/how-can-i-tell-cpan-to-change-the-target-for-the-module-installation