FAQ
I'm hoping some folks find this useful and others who are familiar with
"use CPAN" can help me solve my problem...

As part of my deployment process for a Catalyst app I'm keeping pretty
much the entire dependency stack resident with it in a 'locallib'
directory. As a result I've created the following bootstrapper for the
local libs...

################ BEGIN script/AppBootstrap.pm ####################

package main;

use FindBin;
use Path::Class;

our $PARENT;
our @LIBS;
our @LOCALLIBS;

BEGIN {
$PARENT = dir($FindBin::Bin)->parent;

push @LIBS, $PARENT->subdir('lib')->stringify;
push @LIBS, $PARENT->subdir('ext-lib')->stringify;

unless ( $ENV{SKIP_LOCALLIB} ) {
push @LIBS, $PARENT->subdir('locallib', 'lib', 'perl5',
'site_perl')->stringify;
push @LOCALLIBS, $PARENT->subdir('locallib')->stringify;
}
}

use lib(@LIBS);
use local::lib(@LOCALLIBS);

1;

#################### END #####################



It's a little bit system-dependent, but it still works quite well for us
because we run a lot of identical Linux VMs. So, now in all my 'myapp_'
scripts I can just use the following piece of code to bootstrap and call
up the app

###################### BEGIN #################

use FindBin;
use lib("$FindBin::Bin");
use AppBootstrap;

use MyApp;

################# END #######################



I'm to the point, however that I really want a clean way of installing
additional dependencies into my locallib via CPAN - something like
another myapp_cpan.pl script that I can just invoke and get a properly
configured CPAN shell. I've put something together, but it doesn't
really work the way I'd like...

################# BEGIN script/myapp_cpan_locallib.pl ###############

#!perl

use strict;
use warnings;

BEGIN {
$ENV{CATALYST_DEBUG} = 0;
$ENV{CATALYST_SCRIPT_GEN} = 31;
}

use FindBin;
use lib("$FindBin::Bin");
use AppBootstrap;

use Path::Class;
use CPAN ();

my $APP_DIR = dir($FindBin::Bin)->parent->stringify;

print "Using APP_DIR: $APP_DIR\n";

$ENV{PERL5LIB} ||= "";
$ENV{PERL5LIB}
= join(':',
$ENV{PERL5LIB},
"$APP_DIR/locallib/lib/perl5/site_perl",
"$APP_DIR/locallib/lib/perl5/"
);

CPAN::Shell->mkmyconfig('~/.cpan/CPAN/MyConfig.pm');
CPAN::Shell->o('conf', 'makepl_arg', "PREFIX=$APP_DIR/locallib");
CPAN::Shell->o('conf', 'mbuildpl_arg', "--install_base
$APP_DIR/locallib");
CPAN::Shell->o('conf', 'commit', '~/.cpan/CPAN/MyConfig.pm');
CPAN::shell;

############################### END #################################


1st - CPAN wants to run the configuration system each time I run this
even though I'm invoking a commit of MyConfig.pm. This doesn't bother me
too much, because it auto populates the values, but it may be a cause of
my 2nd problem.

2nd - When attempting to install modules via the command line, many of
them fail during the build with the following message...


################### BEGIN ###################################

CPAN.pm: Going to build
L/LB/LBR/Catalyst-Plugin-Session-Store-Cache-0.01.tar.gz

Checking if your kit is complete...
Looks good
Only one of PREFIX or INSTALL_BASE can be given. Not both.
Warning: No success on command[/usr/bin/perl Makefile.PL
PREFIX=/home/mpitts/dev/MyApp/locallib]
LBR/Catalyst-Plugin-Session-Store-Cache-0.01.tar.gz
/usr/bin/perl Makefile.PL PREFIX=/home/mpitts/dev/MyApp/locallib --
NOT OK
Running make test
Make had some problems, won't test
Running make install
Make had some problems, won't install
Failed during this command:
LBR/Catalyst-Plugin-Session-Store-Cache-0.01.tar.gz: writemakefile NO
'/usr/bin/perl Makefile.PL PREFIX=/home/mpitts/dev/MyApp/locallib '
returned status 65280

######################## END ##############################


I've tried in vain to figure out where/how/why INSTALL_BASE is set, but
alas I have failed.

Any assistance on this is much appreciated.

v/r

-matt

Search Discussions

  • Ian Sillitoe at Dec 3, 2008 at 5:38 pm

    I've tried in vain to figure out where/how/why INSTALL_BASE is set, but
    alas I have failed.
    Perhaps I'm missing something - are you talking about this:

    CPAN::Shell->o('conf', 'mbuildpl_arg', "--install_base
    $APP_DIR/locallib");
    ?


    --
    Ian Sillitoe
    CATH Team -- http://cathdb.info
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20081203/463d9771/attachment.htm
  • Matt Pitts at Dec 4, 2008 at 3:35 pm

    From: Ian Sillitoe
    Sent: Wednesday, December 03, 2008 12:38 PM
    To: The elegant MVC web framework
    Subject: Re: [Catalyst] Local lib bootstrapper and CPAN installer

    I've tried in vain to figure out where/how/why INSTALL_BASE is set,
    but
    alas I have failed.
    Perhaps I'm missing something - are you talking about this:
    CPAN::Shell->o('conf', 'mbuildpl_arg', "--install_base
    $APP_DIR/locallib");

    ?
    No the mbuildpl_arg setting is not the culprit as I have removed it
    without any change.

    v/r
    -matt
  • Matt Pitts at Dec 4, 2008 at 3:50 pm
    After digging into this a bit more it appears as though it has something
    to do with how I'm using local::lib. I was able to duplicate the error
    outside of the CPAN shell by trying to build a module with the
    following...


    mpitts@a3linux08:~/.cpan/build/Catalyst-Plugin-Cache-Memcached-0.71>
    perl -Mlocal::lib=~/dev/MyApp/locallib/ Makefile.PL
    PREFIX=/home/A3/mpitts/dev/MyApp/locallib/
    Cannot determine perl version info from
    lib/Catalyst/Plugin/Cache/Memcached.pm
    *** Module::AutoInstall version 1.03
    *** Checking for Perl dependencies...
    [Core Features]
    - Catalyst::Runtime ...missing. (would need 5.7006)
    - Cache::Memcached ...missing.
    ==> Auto-install the 2 mandatory module(s) from CPAN? [y] n
    ==> The module(s) are mandatory! Really skip? [n] y
    *** Module::AutoInstall configuration finished.
    Warning: prerequisite Cache::Memcached 0 not found.
    Warning: prerequisite Catalyst::Runtime 5.7006 not found.
    Only one of PREFIX or INSTALL_BASE can be given. Not both.
    mpitts@a3linux08:~/.cpan/build/Catalyst-Plugin-Cache-Memcached-0.71>


    If I remove the -Mlocal::lib option then it warns me about missing
    dependencies by still builds OK...


    mpitts@a3linux08:~/.cpan/build/Catalyst-Plugin-Cache-Memcached-0.71>
    perl Makefile.PL PREFIX=/home/A3/mpitts/dev/MyApp/locallib/
    Cannot determine perl version info from
    lib/Catalyst/Plugin/Cache/Memcached.pm
    *** Module::AutoInstall version 1.03
    *** Checking for Perl dependencies...
    [Core Features]
    - Catalyst::Runtime ...missing. (would need 5.7006)
    - Cache::Memcached ...missing.
    ==> Auto-install the 2 mandatory module(s) from CPAN? [y] n
    ==> The module(s) are mandatory! Really skip? [n] y
    *** Module::AutoInstall configuration finished.
    Warning: prerequisite Cache::Memcached 0 not found.
    Warning: prerequisite Catalyst::Runtime 5.7006 not found.
    Writing Makefile for Catalyst::Plugin::Cache::Memcached
    mpitts@a3linux08:~/.cpan/build/Catalyst-Plugin-Cache-Memcached-0.71>


    BTW, I know C::P::Cache::Memcached is no longer needed with Cache, this
    was just a test.

    So I started wondering if maybe I don't even need to specify PREFIX via
    makepl_arg because local::lib has already setup everything for me and
    the module will automatically be installed to my locallib directory.
    Voila, by changing my CPAN shell invoker to *not* set makepl_arg and
    mbuildpl_arg and removing the existing MyConfig.pm, I was able to
    download, test and install the latest DateTime into my locallib all from
    within my CPAN shell. Very cool.

    My hats off to mst for the wonderful local::lib.

    Here is my new cpan shell invoker if anyone else is interested...

    ##################### BEGIN script/myapp_cpan_locallib.pl
    ########################


    #!/usr/bin/perl

    use strict;
    use warnings;

    BEGIN {
    $ENV{CATALYST_DEBUG} = 0;
    $ENV{CATALYST_SCRIPT_GEN} = 31;
    }

    use FindBin;
    use lib("$FindBin::Bin");
    use AppBootstrap;

    use Path::Class;
    use CPAN ();

    my $APP_DIR = dir($FindBin::Bin)->parent->stringify;

    print "Using APP_DIR: $APP_DIR\n";

    CPAN::Shell->mkmyconfig('~/.cpan/CPAN/MyConfig.pm');
    CPAN::Shell->o('conf', 'commit', '~/.cpan/CPAN/MyConfig.pm');
    CPAN::shell;


    ###################################### END
    #######################################

    v/r

    -matt
    -----Original Message-----
    From: Matt Pitts
    Sent: Wednesday, December 03, 2008 11:32 AM
    To: The elegant MVC web framework
    Subject: [Catalyst] Local lib bootstrapper and CPAN installer

    I'm hoping some folks find this useful and others who are familiar with
    "use CPAN" can help me solve my problem...

    As part of my deployment process for a Catalyst app I'm keeping pretty
    much the entire dependency stack resident with it in a 'locallib'
    directory. As a result I've created the following bootstrapper for the
    local libs...

    ################ BEGIN script/AppBootstrap.pm ####################

    package main;

    use FindBin;
    use Path::Class;

    our $PARENT;
    our @LIBS;
    our @LOCALLIBS;

    BEGIN {
    $PARENT = dir($FindBin::Bin)->parent;

    push @LIBS, $PARENT->subdir('lib')->stringify;
    push @LIBS, $PARENT->subdir('ext-lib')->stringify;

    unless ( $ENV{SKIP_LOCALLIB} ) {
    push @LIBS, $PARENT->subdir('locallib', 'lib', 'perl5',
    'site_perl')->stringify;
    push @LOCALLIBS, $PARENT->subdir('locallib')->stringify;
    }
    }

    use lib(@LIBS);
    use local::lib(@LOCALLIBS);

    1;

    #################### END #####################



    It's a little bit system-dependent, but it still works quite well for
    us
    because we run a lot of identical Linux VMs. So, now in all my 'myapp_'
    scripts I can just use the following piece of code to bootstrap and
    call
    up the app

    ###################### BEGIN #################

    use FindBin;
    use lib("$FindBin::Bin");
    use AppBootstrap;

    use MyApp;

    ################# END #######################



    I'm to the point, however that I really want a clean way of installing
    additional dependencies into my locallib via CPAN - something like
    another myapp_cpan.pl script that I can just invoke and get a properly
    configured CPAN shell. I've put something together, but it doesn't
    really work the way I'd like...

    ################# BEGIN script/myapp_cpan_locallib.pl ###############

    #!perl

    use strict;
    use warnings;

    BEGIN {
    $ENV{CATALYST_DEBUG} = 0;
    $ENV{CATALYST_SCRIPT_GEN} = 31;
    }

    use FindBin;
    use lib("$FindBin::Bin");
    use AppBootstrap;

    use Path::Class;
    use CPAN ();

    my $APP_DIR = dir($FindBin::Bin)->parent->stringify;

    print "Using APP_DIR: $APP_DIR\n";

    $ENV{PERL5LIB} ||= "";
    $ENV{PERL5LIB}
    = join(':',
    $ENV{PERL5LIB},
    "$APP_DIR/locallib/lib/perl5/site_perl",
    "$APP_DIR/locallib/lib/perl5/"
    );

    CPAN::Shell->mkmyconfig('~/.cpan/CPAN/MyConfig.pm');
    CPAN::Shell->o('conf', 'makepl_arg', "PREFIX=$APP_DIR/locallib");
    CPAN::Shell->o('conf', 'mbuildpl_arg', "--install_base
    $APP_DIR/locallib");
    CPAN::Shell->o('conf', 'commit', '~/.cpan/CPAN/MyConfig.pm');
    CPAN::shell;

    ############################### END #################################


    1st - CPAN wants to run the configuration system each time I run this
    even though I'm invoking a commit of MyConfig.pm. This doesn't bother
    me
    too much, because it auto populates the values, but it may be a cause
    of
    my 2nd problem.

    2nd - When attempting to install modules via the command line, many of
    them fail during the build with the following message...


    ################### BEGIN ###################################

    CPAN.pm: Going to build
    L/LB/LBR/Catalyst-Plugin-Session-Store-Cache-0.01.tar.gz

    Checking if your kit is complete...
    Looks good
    Only one of PREFIX or INSTALL_BASE can be given. Not both.
    Warning: No success on command[/usr/bin/perl Makefile.PL
    PREFIX=/home/mpitts/dev/MyApp/locallib]
    LBR/Catalyst-Plugin-Session-Store-Cache-0.01.tar.gz
    /usr/bin/perl Makefile.PL PREFIX=/home/mpitts/dev/MyApp/locallib --
    NOT OK
    Running make test
    Make had some problems, won't test
    Running make install
    Make had some problems, won't install
    Failed during this command:
    LBR/Catalyst-Plugin-Session-Store-Cache-0.01.tar.gz: writemakefile NO
    '/usr/bin/perl Makefile.PL PREFIX=/home/mpitts/dev/MyApp/locallib '
    returned status 65280

    ######################## END ##############################


    I've tried in vain to figure out where/how/why INSTALL_BASE is set, but
    alas I have failed.

    Any assistance on this is much appreciated.

    v/r

    -matt

    _______________________________________________
    List: Catalyst@lists.scsys.co.uk
    Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
    Searchable archive: http://www.mail-
    archive.com/catalyst@lists.scsys.co.uk/
    Dev site: http://dev.catalyst.perl.org/

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedDec 3, '08 at 4:32p
activeDec 4, '08 at 3:50p
posts4
users2
websitecatalystframework.org
irc#catalyst

2 users in discussion

Matt Pitts: 3 posts Ian Sillitoe: 1 post

People

Translate

site design / logo © 2022 Grokbase