首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >cpan/cpanm在本地安装的CPAN模块在没有手动干预的情况下无法使用

cpan/cpanm在本地安装的CPAN模块在没有手动干预的情况下无法使用
EN

Stack Overflow用户
提问于 2014-07-13 10:24:05
回答 2查看 832关注 0票数 2

我已经将我的应用程序打包为Perl模块,它无法使用cpancpanm命令进行安装。问题是,这些命令--如果不是根用户运行--将先决条件模块安装到~/perl5 5目录中。但是,我的~/perl5 5目录没有包含在@INC中。

这导致了cpanm的以下令人困惑的输出:

代码语言:javascript
复制
$ cpanm --installdeps .
--> Working on .
Configuring my-module-0.001 ... OK
==> Found dependencies: Image::Size
--> Working on Image::Size
Fetching http://www.cpan.org/authors/id/R/RJ/RJRAY/Image-Size-3.232.tar.gz ... OK
Configuring Image-Size-3.232 ... OK
Building and testing Image-Size-3.232 ... OK
Successfully installed Image-Size-3.232
! Installing the dependencies failed: Module 'Image::Size' is not installed
! Bailing out the installation for my-module-0.001.
1 distribution installed

如您所见,它成功地下载、测试和安装了Image::Size模块,但随后尝试使用它,但失败了。

我知道我可以通过将环境变量$PERL5LIB设置为“~/perl5 5/lib/perl5 5”并在我的$PATH中添加“~/perl5 5/bin”来解决这个问题,但我很想知道这种情况最初是如何产生的。我想为我的应用程序的用户提供尽可能简单的安装说明,并且手动修改环境变量不是我计划要指导他们的事情。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-07-14 19:09:22

如果使用bash,可以将本地::lib添加类似于.bashrc文件的内容

代码语言:javascript
复制
# adds $HOME/perl5/bin to PATH
[ $SHLVL -eq 1 ] && eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)"

这应该能解决你的问题。问题在于您的本地系统的配置方式,因此需要对其进行调整,而不是在不需要Dist::Zilla的情况下将其引入混合系统。

票数 0
EN

Stack Overflow用户

发布于 2014-07-13 19:04:09

这是我自己解决这个问题的办法。我切换到地区::Zilla,并为我的用户提供了以下安装说明:

代码语言:javascript
复制
Installation instructions
=========================

To install this program you need Dist::Zilla, which can be installed
by running the following command as root:

    cpan Dist::Zilla

After that, make sure you're in directory where this INSTALL file is,
and run the following command as root:

    dzil install
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24721671

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档