我的mac机很旧(Mac OS X 10.6.8),我对如何升级perl模块有疑问File::Path
。
我主要使用Latexmk编译LaTeX文档,这基本上是一个perl脚本。它需要File::Path
版本2.08,但是我的机器上已经过时(版本2.07_02)。这是我在运行latexmk
命令时收到的错误消息。
>> latexmk doc.tex
File::Path version 2.08 required--this is only version 2.07_02 at /usr/texbin/latexmk line 129.
当我cpan
以非root用户身份运行并尝试通过运行命令来升级此软件包时,upgrade File::Path
在屏幕上显示了此消息。
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ERROR: Can't create '/Library/Perl/Updates/5.10.0/File'
mkdir /Library/Perl/Updates/5.10.0/File: Permission denied at
/System/Library/Perl/5.10.0/ExtUtils/Install.pm line 479
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
at -e line 1
make: *** [pure_perl_install] Error 13
DLAND/File-Path-2.09.tar.gz
/usr/bin/make install -- NOT OK
Warning (usually harmless): 'YAML' not installed, will not store persistent state
Failed during this command:
DLAND/File-Path-2.09.tar.gz : install NO
是否可以cpan
在Mac OS X中以非root用户身份升级perl模块?
您不能将现有安装修改为非root用户。但是,您可以在主目录(或具有写访问权限的任何位置)中安装CPAN模块,然后优先加载该模块(在大多数情况下。模块之间可能存在冲突,但是您可以在这里进行)。
cpan
在perlfaq中有通过该工具执行此操作的说明。但这可能有点奇怪。使用cpanm
通常建议。
https://stackoverflow.com/questions/2980297/how-can-i-use-cpan-as-a-non-root-user提供了有关安装的详细说明cpanm
。
然后,在安装后,您只需要使用它而不是系统模块即可。有几种方法可以做到这一点。
您可以将PERL5LIB设置为本地目录。举个例子:
$ export PERL5LIB=~/perl5
$ perl myprog
如果仅需要少量脚本就可以执行此操作,则可以在脚本本身中添加路径:
#!/bin/perl
use lib '/home/me/perl5';
use File::Path;
这些都可以满足您的需求,但是如果您只是在测试东西,还可以像这样暂时在路径中添加位置
$ perl -I ~/perl5 myprog
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句