cpanm perl模块安装到用户目录

时间:2012-01-28 20:02:54

标签: perl cpan

我是Perl的新手,正在尝试通过运行

来安装Net :: SFTP模块
cpanm Net::SFTP

我尝试了安装,5-10分钟后,它失败了以下

! Configure failed for Math-GMP-2.06. See /Users/applemacbookpro/.cpanm/build.log for details.
! Bailing out the installation for Net-SSH-Perl-1.34. Retry with --prompt or --force.
! Bailing out the installation for Net-SFTP-0.10. Retry with --prompt or --force.
19 distributions installed

但是,当我再次尝试安装时,我注意到了这条消息:

Can't write to /opt/local/lib/perl5/site_perl/5.12.3 and /opt/local/bin: Installing modules to /Users/applemacbookpro/perl5

所以,现在我在~/perl5目录中安装了一堆模块 - 如果我使用sudo安装并且我的perl模块位于两个单独的目录中,我是否会遇到问题?

1 个答案:

答案 0 :(得分:2)

Perl根据@INC搜索模块,您可以使用perl -V查看。 (这是一个大写的“V”。)如果您在两个位置安装了模块,那么在@INC中找到的第一个模块将是加载的模块。

Perl通常不知道甚至会查看/Users/applemacbookpro/perl5,所以很有可能找不到那里的模块。

如果您在/Users/applemacbookpro/perl5开始没有任何模块,请随时删除该目录。