如何在没有 root 权限的情况下安装 Perl 模块?

问题描述:

我在一台没有 root 权限的 Linux 机器上.我想通过 CPAN 将一些包安装到我的主目录中,这样当我运行 Perl 时,它就能看到它.

I am on a Linux machine where I have no root privileges. I want to install some packages through CPAN into my home directory so that when I run Perl, it will be able to see it.

我运行了 cpan,它要求提供一些配置选项.它要求某个目录,它建议 ~/perl 用于非 root 用户".尽管如此,当我尝试安装软件包时,它在 make install 步骤失败,因为我没有对 /usr/lib/perl5/whatever 的写访问权限.

I ran cpan, which asked for some coniguration options. It asked for some directory, which it suggested ~/perl "for non-root users". Still, when I try to install a package, it fails at the make install step, because I don't have write access to /usr/lib/perl5/whatever.

如何配置 CPAN 以便我可以将软件包安装到我的主目录中?

How can I configure CPAN so that I can install packages into my home directory?

参见 local::lib.

安装后,您可以执行以下操作:

Once you have it installed, you can do:

perl -MCPAN -Mlocal::lib -e 'CPAN::install(LWP)'