Custom perl installation cannot find Git.pm

核能气质少年 提交于 2019-12-23 15:39:30

问题


I have installed my own copy of Perl in my home directory, but I have some Perl scripts that require Git.pm, which is part of the Git distribution and not installable from CPAN. The Git.pm used by the system perl resides at /usr/share/perl5/Git.pm. How can I make this Git.pm available to a custom perl install, or get another copy of Git.pm installed in the correct location? Should I just copy it into my own Perl's lib directory?


回答1:


Git.pm is self-contained, so copying it in a directory part of your private perl @INC. It requires Error.pm (with version greater or equal to 0.15009), so don't forget to install that module as well.

If you're looking for a Git wrapper (and not specifically Git.pm), there are several available on CPAN (in alphabetical order):

  • Git::Class
  • Git::Repository
  • Git::Wrapper



回答2:


You can follow the article Perl modules FAQ - What to do when Perl modules aren't in their normal locations, and add your module in the @INC variable path, by modifying directly your Perl script which needs Git.pm.

#!/usr/bin/perl
use lib "/home/george/modules";
print "\@INC is @INC\n";

use the use lib statement to add your search directory to Perl's search path.




回答3:


To control where Perl searches for modules, use PERL5LIB (or PERLLIB).

To have your module/script use some module at non-standard location, use use lib "<dir>"; (thought I think it is usually deprecated).

To install Perl modules locally from CPAN, use local::lib.



来源:https://stackoverflow.com/questions/6159854/custom-perl-installation-cannot-find-git-pm

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