三生石@ 2010-06-05 12:20 采纳率: 100%
浏览 305
已采纳

如何使用 CPAN 作为非根用户?

I want to install perl modules on a shared server on which I do not have root access. How can I do this? They also seem to have an older version of CPAN (it complains about that when running the command), is it possible to update the CPAN command being used from my account without requiring root access?

转载于:https://stackoverflow.com/questions/2980297/how-can-i-use-cpan-as-a-non-root-user

  • 写回答

4条回答 默认 最新

  • 乱世@小熊 2010-06-05 14:23
    关注

    The easiest method I have found so far is to say

    wget -O- http://cpanmin.us | perl - -l ~/perl5 App::cpanminus local::lib
    eval `perl -I ~/perl5/lib/perl5 -Mlocal::lib`
    echo 'eval `perl -I ~/perl5/lib/perl5 -Mlocal::lib`' >> ~/.profile
    echo 'export MANPATH=$HOME/perl5/man:$MANPATH' >> ~/.profile
    

    This assumes your profile is named .profile, you may need to change that to be .bash_profile, .bashrc, etc. After that you can install modules by saying

    cpanm Module::Name
    

    and simply use them the same way you would if the were installed in the root directories.


    What follows is a brief explanation of what the commands above do.

    wget -O- http://cpanmin.us fetches the latest version of cpanm and prints it to STDOUT which is then piped to perl - -l ~/perl5 App::cpanminus local::lib. The first - tells perl to expect the program to come in on STDIN, this makes perl run the version of cpanm we just downloaded. perl passes the rest of the arguments to cpanm. The -l ~/perl5 argument tells cpanm where to install Perl modules, and the other two arguments are two modules to install. [App::cpanmins]1 is the package that installs cpanm. local::lib is a helper module that manages the environment variables needed to run modules in local directory.

    After those modules are installed we run

    eval `perl -I ~/perl5/lib/perl5 -Mlocal::lib`
    

    to set the environment variables needed to use the local modules and then

    echo 'eval `perl -I ~/perl5/lib/perl5 -Mlocal::lib`' >> ~/.profile
    

    to ensure we will be able to use them the next time we log in.

    echo 'export MANPATH=$HOME/perl5/man:$MANPATH' >> ~/.profile
    

    will hopefully cause man to find the man pages for your local modules.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。