App-local-lib-helper
view release on metacpan or search on metacpan
README.mkdn view on Meta::CPAN
## localenv
This is a perl script that runs a single command in [local::lib](http://search.cpan.org/perldoc?local::lib) aware context.
You can use the `helper-name` option to set a different name.
Typically I will use this to 'enable' a previously setup [local::lib](http://search.cpan.org/perldoc?local::lib) with
commands like:
~/mylocallib/bin/localenv bash
~/mylocallib/bin/localenv screen
Or I can use it to run a single command wrapped in the [local::lib](http://search.cpan.org/perldoc?local::lib) target
and exit cleanly:
~/mylocallib/bin/localenv perl app.pl
~/mylocallib/bin/localenv plackup app.psgi
## localenv-relative
NOTE: Experimental feature. Please prefer using [localenv](#pod_localenv) unless you
absolutely need this functionality.
This perl script functions (or should function) identically to [localenv](http://search.cpan.org/perldoc?localenv) as
documented. However, instead of having hardcoded full paths to your Perl
binary and [local::lib](http://search.cpan.org/perldoc?local::lib) target directories, we instead try to use relative
pathing. For example, here is the helper script built on my server for the
standard [localenv](#pod_localenv) script:
#!/Users/johnn/perl5/perlbrew/perls/perl-5.14.1/bin/perl
use strict;
use warnings;
use lib '/Users/johnn/locallib_5_14_1/lib/perl5';
use local::lib '/Users/johnn/locallib_5_14_1';
unless ( caller ) {
if ( @ARGV ) {
exec @ARGV;
}
}
And here is the example same version for the relative script:
#!/usr/bin/env perl
use strict;
use warnings;
use FindBin;
use File::Spec;
use lib File::Spec->catdir($FindBin::Bin, '..', 'lib', 'perl5');
use local::lib File::Spec->catdir($FindBin::Bin, '..');
unless ( caller ) {
if ( @ARGV ) {
exec @ARGV;
}
}
The goal here is to be more friendly when you need to relocate your
installation of Perl and/or your [local::lib](http://search.cpan.org/perldoc?local::lib) target directory. You might
wish to try this if you are copying a 'seed' Perl and [local::lib](http://search.cpan.org/perldoc?local::lib) setup to
multiple developer home directories (as a way to speed up first time developer
setup, for example) or if your deployment system copies your application from
your build enviroment to a QA or Production that is not identical.
Personally I prefer to build Perl and my application in each location that is
different, since I find that works very effectively. However I understand some
shops have existing build systems that deploy code by copying Perl dependencies
from box to box, and these boxes are not always identical in directory layout.
For example, there might be a build or integration point in development, with
a [local::lib](http://search.cpan.org/perldoc?local::lib) target of `/home/integration/webapp-cpan-locallib` and you
wish to copy that directory recursively to your qa/production server, which
might be located at `/home/qa/local-lib`.
I'd like to accomodate this approach as best I can, however I can't be certain
that moving Perl and [local::lib](http://search.cpan.org/perldoc?local::lib) around rather than performing a true install
is going to work consistently. Caveat emptor!
Please also note that the following shell snippets are not relative tested.
## localenv-bashrc
a snippet suitable for sourcing in your .bashrc, which will automatically
activate a local-lib at login. Name will follow from `helper-name`.
Here's an example of the line I might add to .bashrc (assumes you have setup
[local::lib](http://search.cpan.org/perldoc?local::lib) in `$HOME/mylocal`
source $HOME/mylocal/localenv-bashrc
Then next time you open a shell you should see that `$PATH` and `PERL5LIB`
have been properly changed.
## localenv-cshrc
a snippet suitable for sourcing in your .cshrc, which will automatically
activate a local-lib at login. Name will follow from `helper-name`.
# AUTHOR
John Napiorkowski ` <<jjnapiork@cpan.org`> >
# COPYRIGHT & LICENSE
Copyright 2011, John Napiorkowski
This program is free software; you can redistribute it and/or modify it under
the same terms as Perl itself.
( run in 0.534 second using v1.01-cache-2.11-cpan-71847e10f99 )