Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
executable file 83 lines (61 sloc) 2.17 KB
#!/usr/bin/env perl
# vim: set filetype=perl:
# env is a perl script similar in concept to /usr/bin/env
# If you have a local-lib5 directory then this script will set it up for
# you as it executes.
# If used like /usr/bin/env then it will run other commands based on
# your current path settings (with a local::lib environment if present)
# e.g. script/env bash
# NOTE: This environment _IS NOT_ self contained
# If included inside another perl script, then it will be a no-op if
# a local::lib environment is not present, but if one is, it will be
# used as a --self-contained environment, expected to contain all non-core
# dependencies for your perl
# e.g.
# use FindBin;
# BEGIN { do "$FindBin::Bin/env" or die $@ }
# The local::lib behavior can be explicitly enabled or disabled by setting
# the CATALYST_LOCAL_LIB enviromnent variable to true or false.
use strict;
use warnings;
use Carp;
use lib;
use FindBin;
use File::Spec ();
use Cwd ();
use CPAN 'install';
# Look up to see find Makefile.PL aka the base of the local::lib install.
my $lookup; $lookup = sub {
my $dir = $_[0] || $FindBin::Bin;
return '' if Cwd::abs_path($dir) eq File::Spec->rootdir;
my $tryfile = File::Spec->catfile($dir, "Makefile.PL");
return -r $tryfile ? $dir : $lookup->( File::Spec->catdir($dir, File::Spec->updir) );
my $basedir = $lookup->();
$basedir ||= '';
my $target = "$basedir/local-lib5";
my $on = -d $target;
Carp::confess("Could not find local-lib5 from '$FindBin::Bin'")
if ($on && ! length $basedir);
if ( $on ) {
# So we can find local::lib when fully self contained
# . for CPAN + app dir
my @include = ('.', "$basedir/lib");
$ENV{PERL5LIB} = join ':', @include;
# Sorry kane ;)
require lib::core::only;
require local::lib;
local::lib->import( $target );
install $_ for @ARGV;
} else {
die "No local::lib configured.";
Jump to Line
Something went wrong with that request. Please try again.