简体   繁体   English

如何使用cpan工具安装本地模块?

[英]How can I install local modules with the cpan tool?

my admin has given me sudo rights for 我的管理员给了我sudo的权利

cpan

I also need to install a couple of non-CPAN modules (Atlassian Crowd -> svn connector) to the global PERL5LIB. 我还需要在全局PERL5LIB上安装几个非CPAN模块(Atlassian Crowd - > svn连接器)。

I vaguely remember that cpan can install from local sources, without pulling modules from the web. 我依稀记得cpan可以从本地安装,而无需从网络上拔出模块。

any pointers? 任何指针? can I do it or should I just have him install those modules manually as root (a major hassle for me)? 我可以这样做,还是应该让他以root身份手动安装这些模块(这对我来说是一个很大的麻烦)? thanks! 谢谢!

If you want to install the Perl distribution in the current directory, use the dot instead of a filename: 如果要在当前目录中安装Perl发行版,请使用点而不是文件名:

 cpan .

If you are using one of the latest versions of the cpan program (not the one that currently comes with CPAN.pm), you can use the -j switch to specify an alternate configuration file where you can set the --install_base or INSTALL_BASE directives, and also set values for options like connect_to_internet_ok . 如果您使用的是最新版本的cpan程序(不是当前CPAN.pm附带的程序),则可以使用-j开关指定备用配置文件,您可以在其中设置--install_baseINSTALL_BASE指令,还为connect_to_internet_ok选项设置值。

 cpan -j /path/to/Config.pm Foo::Bar

If you want to modify your current config to make your alternate config file, use -J to get the file text: 如果要修改当前配置以生成备用配置文件,请使用-J获取文件文本:

 cpan -J

Ideally, instead for giving you superuser priveleges, that sysadmin would have created a group for Perl admins, would have specified a directory for module installations owned by that group, and added you to that group. 理想情况下,系统管理员可以为Perl管理员创建一个组,而不是为您提供超级用户权限,为该组拥有的模块安装指定一个目录,并将您添加到该组。 You wouldn't need any special powers then. 那时你不需要任何特殊的权力。

sudo rights to cpan -i should do the trick: cpan -i sudo权利应该做的伎俩:

bash-3.2$ cpan -i Foo::Bar
CPAN: File::HomeDir loaded ok (v0.80)
CPAN: Storable loaded ok (v2.18)
...

I'm not familiar with installing from files via the cpan script. 我不熟悉通过cpan脚本从文件安装。 In the cpan shell you can look into the module directory and manually build/install from there if you want, but the original tar file still came from the repository, and the cpan command line doesn't seem to have that function (if it did I doubt the admin would grand sudo rights to it since then you'd have a root shell). 在cpan shell中,您可以look模块目录并根据需要手动构建/安装,但原始tar文件仍然来自存储库,并且cpan命令行似乎没有该功能(如果它我怀疑管理员是否会拥有盛大的sudo权利,因为那时你有一个root shell)。

Update: brian d foy suggests that I'm wrong about giving sudo to the cpan command being the same as giving a root shell - here's why I'm right: 更新:brian d foy建议我给cap命令提供sudo与给root shell一样是错的 - 这就是为什么我是对的:

bash-3.2# whoami
aufflick
bash-3.2# sudo cpan
cpan[1]> o conf shell bash
cpan[2]> look Acme::Bleach
..... downloads and extracts Acme::Bleach ...
CPAN: File::Temp loaded ok (v0.18)
Working directory is /Users/aufflick/.cpan/build/Acme-Bleach-1.12-v768Dv
bash-3.2# whoami
root
bash-3.2# 

You don't actually need your admin to give you rights to install CPAN modules. 您实际上并不需要管理员授予您安装CPAN模块的权限。 In fact local::lib is a better solution for a number of reasons. 事实上, local :: lib是一个更好的解决方案,原因有很多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM