在 linux ubuntu 中使用 CPAN 时,我应该使用 sudo / 作为 root 还是作为我的默认用户运行它
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/9409888/
Warning: these are provided under cc-by-sa 4.0 license.  You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
when using CPAN in linux ubuntu should I run it using sudo / as root or as my default user
提问by nelaaro
I get errors like this
我收到这样的错误
Running make install Prepending blib/arch and blib/lib of 17 build dirs to PERL5LIB; for 'install' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ERROR: Can't create '/usr/local/man/man3' Do not have write permissions on '/usr/local/man/man3'
  You may have to su to root to install the package
  (Or you may want to run something like
    o conf make_install_make_command 'sudo make'
Will I still be able to run the software / library's that perl / CPAN installs as a my default user.
我是否仍然能够以我的默认用户身份运行 perl/CPAN 安装的软件/库。
What is the best practice when working with CPAN / Perl on Debian like systems.
在类似 Debian 的系统上使用 CPAN/Perl 时的最佳实践是什么。
采纳答案by cjm
You should run the cpancommand as your normal user.  You have two choices:
您应该cpan以普通用户身份运行该命令。你有两个选择:
- Install modules into a directory under your home dir. local::libwill help you set that up. 
- Configure - cpanto use- sudoduring the install phase. You do that by starting the- cpanshell and typing:- o conf make_install_make_command 'sudo make' o conf mbuild_install_build_command 'sudo ./Build' o conf commit- The first line configures MakeMakerto use - sudo. The second line does the same for Module::Build. The third line saves the changes.
- 将模块安装到您的主目录下的目录中。 local::lib将帮助您进行设置。 
- 配置 - cpan为- sudo在安装阶段使用。您可以通过启动- cpanshell 并键入:- o conf make_install_make_command 'sudo make' o conf mbuild_install_build_command 'sudo ./Build' o conf commit- 第一行将MakeMaker配置为使用 - sudo. 第二行对Module::Build执行相同的操作。第三行保存更改。
回答by choroba
If you want to install modules as a non-root user, you can configure your cpan to use an install base:
如果您想以非 root 用户身份安装模块,您可以将 cpan 配置为使用安装库:
makepl_arg         [INSTALL_BASE=/home/nelaar/perl]
mbuildpl_arg       [--install_base=/home/nelaar/perl]
And set PERL5LIB accordingly to /home/nelaar/perl/lib/perl5.
并将 PERL5LIB 相应地设置为/home/nelaar/perl/lib/perl5.
回答by Quentin
If you want to install your modules for your own use, then you should be running it as yourself. Use local::libto set up your environment variables so that this works nicely. You may wish to look at cpan minusas an alternative to the the default cpan installer.
如果您想安装自己的模块供您自己使用,那么您应该自己运行它。使用local::lib来设置您的环境变量,以便它很好地工作。您可能希望查看cpan minus作为默认 cpan 安装程序的替代方案。
You may also wish to consider using perlbrewto install a newer version of perl that is completely independent from the system perl.
您可能还希望考虑使用perlbrew安装完全独立于系统 perl 的较新版本的 perl。
If you want to install them system wide, then I recommend (since you have tagged this ubuntu) looking at dh-make-perlto produce .deb files that you can install and uninstall with dpkg.
如果你想在系统范围内安装它们,那么我建议(因为你已经标记了这个ubuntu)查看dh-make-perl来生成 .deb 文件,你可以使用 dpkg 安装和卸载这些文件。

