Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Personal library with CPAN

by Zaxo (Archbishop)
on Jun 07, 2004 at 05:55 UTC ( #361887=note: print w/ replies, xml ) Need Help??


in reply to Personal library with CPAN

Copy the system CPAN::Config module to ~/.cpan/CPAN/MyConfig.pm and edit it to provide your own build paths and make directives, particularly the installation prefix directory.

You will probably want to set up the PERL5LIB environment variable to let perl find your private installations.

Update: Some adaptation of this sequence of commands will set you up (tested):

$ mkdir ~/.cpan $ mkdir ~/.cpan/CPAN $ cd ~/.cpan/CPAN $ cp /usr/lib/perl5/5.8.4/CPAN/Config.pm MyConfig.pm $ perl -pi -e's!/root/\.cpan!$ENV{HOME}/.cpan!' MyConfig.pm $ perl -pi -e'/makepl_arg/ && s!\]! PREFIX=$ENV{HOME}]!' MyConfig.pm $ echo "export PERL5LIB=${HOME}/lib/perl5/site_perl/5.8.4/i686-linux:$ +{HOME}/lib/perl5/site_perl/5.8.4" >> ~/.bash_profile $ . ~/.bash_profile $ perl -MCPAN -e shell
That should be all you need to do, as long as the system CPAN setup is similar enough and your shell bash enough.

After Compline,
Zaxo


Comment on Re: Personal library with CPAN
Download Code
Re^2: Personal library with CPAN
by PodMaster (Abbot) on Jun 07, 2004 at 06:24 UTC
    How do you know this?

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

      It's in the, uhhh.., Pod ;-). perldoc CPAN, way down in the "Configuration" section, around page 14 on this terminal.

      After Compline,
      Zaxo

        Brilliant!

        MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
        I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
        ** The third rule of perl club is a statement of fact: pod is sexy.

Re^2: Personal library with CPAN
by monkfan (Curate) on Apr 05, 2005 at 10:28 UTC
    Hi Zaxo,
    The lists of command you provided works great. The really nice things about that set-up is that:

    1. You can call the module without having to invoke the standard "use lib" command.
    2. You can call the perldoc of the modules installed locally from anywhere.

    All these happen JUST as it was installed internally as ROOT! It's incredible.
    Would you mind explain which part of the command above that does that? I can somehow guess, but not sure.
    Regards,
    Edward

      Line seven sets and exports the environment variable PERL5LIB in the bash login shell configuration. That is the part which tells Perl where else to look for modules. Technically, Perl adds the path in $PERL5LIB to @INC. The perlrun and perlvar docs tell all.

      The following line sources ~/.bash_profile in the current shell so that Perl has the benefit of PERL5LIB right away. That amounts to rereading the shell config.

      That may fail to influence a web server's Perl environment. If it does, you can use the SetEnv directive in .htaccess or the server configuration for regular cgi scripts. I think PerlSetEnv should work for mod_perl, but mod_perl usually implies enough control that a private perl lib is unnecessary, so I've never tried that setup.

      After Compline,
      Zaxo

Re^2: Personal library with CPAN
by eric256 (Parson) on Mar 09, 2006 at 21:17 UTC

    That seems to work great. But then while installing DBI it dies with the following error

    /usr/local/bin/perl -p -e "s/~DRIVER~/Perl/g" ./Driver.xst > Perl.xsi /usr/local/bin/perl /usr/local/lib/perl5/5.8.0/ExtUtils/xsubpp -typem +ap /usr/local/lib/perl5/5.8.0/ExtUtils/typemap -typemap typemap Perl +.xs > Perl.xsc && mv Perl.xsc Perl.c cc -c -DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.0/BSDPAN" -DHAS_FPSET +MASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -I/usr/local/include +-O -pipe -DVERSION=\"1.50\" -DXS_VERSION=\"1.50\" -DPIC -fPIC "-I +/usr/local/lib/perl5/5.8.0/mach/CORE" -W -Wall -Wpointer-arith -Wbad +-function-cast -Wno-comment -Wno-sign-compare -Wno-cast-qual -DDBI_NO +_THREADS Perl.c cc: permission denied *** Error code 126 Stop in /usr/home/sites/www.whereever.com/whereever/.cpan/build/DBI-1. +50. /usr/bin/make -- NOT OK Running make test Can't test without successful make Running make install make had returned bad status, install seems impossible
    I'll continue to search perlmonks, but i think this might just be a permission setting that is obvious to real unix hackers ;)


    ___________
    Eric Hodges

      Yes, that appears to be a permission problem with -DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.0/BSDPAN". If you need a private cpan directory, you probably don't have write permission there.

      I don't know if this is the source of the problem, but sometimes authors hardcode paths that they should let CPAN.pm figure out. You could try setting and exporting APPLIB_EXP before the build as a workaround.

      After Compline,
      Zaxo

Re^2: Personal library with CPAN
by monkfan (Curate) on May 18, 2006 at 05:20 UTC
    Dear Zaxo,
    I had my CPAN installation setting following your ingenious solution above.
    I never has compilation problem beforehand when running a Perl script (*.pl).

    Recently, while trying a CGI script like below (let's call it 'test.cgi'). I had problem compiling it.
    #!/usr/bin/perl -w use CGI ':standard'; use Mail::Sendmail;
    Although Mail::Sendmail is successfuly installed, my CGI script can't recognize the location. I encounter this strange result.

    When I run this:
    $ perl -c test.cgi # it gives test.cgi syntax OK
    But when I run this with taint:
    $ perl -cT test.cgi It gives: Can't locate Mail/Sendmail.pm in @INC (@INC contains: ~/lib/perl5/site +_perl/5.8.5/ /usr/lib/perl5/5.8.5/i386-linux-thread-multi /usr/lib/pe +rl5/5.8.5 /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi /usr +/lib/perl5/site_perl/5.8.4/i386-linux-thread-multi /usr/lib/perl5/sit +e_perl/5.8.3/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.2/i +386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.1/i386-linux-thre +ad-multi /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi /usr/ +lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl/5.8.4 /usr/lib/per +l5/site_perl/5.8.3 /usr/lib/perl5/site_perl/5.8.2 /usr/lib/perl5/site +_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl / +usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl +5/vendor_perl/5.8.4/i386-linux-thread-multi /usr/lib/perl5/vendor_per +l/5.8.3/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.2/i386 +-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.1/i386-linux-threa +d-multi /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi /usr +/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl/5.8.4 /usr/li +b/perl5/vendor_perl/5.8.3 /usr/lib/perl5/vendor_perl/5.8.2 /usr/lib/p +erl5/vendor_perl/5.8.1 /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl +5/vendor_perl) at temp.cgi line 4. BEGIN failed--compilation aborted at temp.cgi line 4.
    How can I have my cgi script recognize the location of the library? I also tried using "use lib" construct like this:



    but also gives the same symptom.
    Does it has anything to do to the way I install the module following your approach?

    Update:
    That may fail to influence a web server's Perl environment. If it does, you can use the SetEnv directive in .htaccess or the server configuration for regular cgi scripts.
    Just realized you mentioned about the problem above. But how do you actually "SentEnv directive of server config" in my cgi scripts?

    Regards,
    Edward

      In a .htaccess file, put

      SetEnv PERL5LIB /where/the/mods/are/:/where/else/lib
      The web server must be able to read files in those directories, of course. Apache suExec is a great help with that, for security's sake.

      See the apache httpd manual for variations that might be handy. When mod_perl is involved, I believe PerlSetEnv is needed, but I've never tried that.

      After Compline,
      Zaxo

        Zaxo,

        I do not have a root (SU) access. Thus, I believe .htaccess cannot be accessible to me. Am I right?
        Is there a way to include somekind of snippet in my CGI script to do the similar thing?
        As you mentioned also earlier as another alternative.

        Update: Along with Zaxo's suggestion above, I can only get my my script going after inserting the following snippet. For further info.
        #!/usr/bin/perl -w use CGI ':standard'; # Newly inserted BEGIN { if ( $ENV{PERL5LIB} and $ENV{PERL5LIB} =~ /^(.*)$/ ) { # Blindly untaint. Taintchecking is to protect # from Web data; # the environment is under our control. eval "use lib '$_';" foreach ( reverse split( /:/, $1 ) ); } } use Mail::Sendmail;

        Regards,
        Edward
Re^2: Personal library with CPAN
by tinita (Parson) on May 19, 2006 at 12:25 UTC
    With a modern version of CPAN you can use the command mkmyconfig in the CPAN shell. This will create your own ~/.cpan/CPAN/MyConfig.pm
      Since which version of CPAN?

      Regards,
      Edward
Re^2: Personal library with CPAN
by unobe (Scribe) on Apr 11, 2007 at 18:21 UTC
    I just noticed that with the last two releases of ExtUtils::MakeMaker, it looks like INSTALL_BASE is now preferred usage, and --install-base is preferred for Module::Build. (See the latest ExtUtils::MakeMaker::FAQ.) If so, your PERL5LIB will change slightly as will the buildpl_arg in MyConfig.pm.
Re^2: Personal library with CPAN
by monkfan (Curate) on Apr 28, 2008 at 00:32 UTC
    Dear Zaxo,
    How can I make your setting above workable in Mac OSX? Have you ever try it? I can't seem to find proper "Config.pm" in / This is all I have.
    ./System/Library/Perl/5.8.8/darwin-thread-multi-2level/Config.pm ./System/Library/Perl/5.8.8/darwin-thread-multi-2level/Encode/Config.p +m ./System/Library/Perl/5.8.8/ExtUtils/MakeMaker/Config.pm ./System/Library/Perl/5.8.8/Net/Config.pm ./System/Library/Perl/Extras/5.8.8/darwin-thread-multi-2level/ModPerl/ +Config.pm ./System/Library/Perl/Extras/5.8.8/Module/Build/Config.pm

    Regards,
    Edward

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://361887]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (11)
As of 2014-09-16 08:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (158 votes), past polls