[Catalyst] Local lib bootstrapper and CPAN installer [SOLVED]

Matt Pitts mpitts at a3its.com
Thu Dec 4 15:50:57 GMT 2008


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 at 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 at 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 at 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 at 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 [mailto:mpitts at a3its.com]
> 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 at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-
> archive.com/catalyst at lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/



More information about the Catalyst mailing list