How can I install a CPAN module into a local directory?

前端 未结 5 1756
庸人自扰
庸人自扰 2020-11-22 16:17

I\'m using a hosted Linux machine so I don\'t have permissions to write into the /usr/lib directory.

When I try to install a CPAN module by doing the us

5条回答
  •  眼角桃花
    2020-11-22 16:56

    Other answers already on Stackoverflow:

    • How do I install modules locally without root access...
    • How can I use a new Perl module without install permissions?

    From perlfaq8:


    How do I keep my own module/library directory?

    When you build modules, tell Perl where to install the modules.

    For Makefile.PL-based distributions, use the INSTALL_BASE option when generating Makefiles:

    perl Makefile.PL INSTALL_BASE=/mydir/perl
    

    You can set this in your CPAN.pm configuration so modules automatically install in your private library directory when you use the CPAN.pm shell:

    % cpan
    cpan> o conf makepl_arg INSTALL_BASE=/mydir/perl
    cpan> o conf commit
    

    For Build.PL-based distributions, use the --install_base option:

    perl Build.PL --install_base /mydir/perl
    

    You can configure CPAN.pm to automatically use this option too:

    % cpan
    cpan> o conf mbuildpl_arg '--install_base /mydir/perl'
    cpan> o conf commit
    

提交回复
热议问题