lee-pai-long
11/12/2013 - 8:28 PM

Set up plenv, install perl, cpanm, carton, set up environment

Set up plenv, install perl, cpanm, carton, set up environment

#!/bin/bash

# installs plenv, perl, carton, cpanminus, sets up environment in .bash_profile
# from https://github.com/tokuhirom/plenv#readme


PLENV_PERL_VERSION='5.18.1'

if [[ -n "$PERL_MB_OPT" ]]; then
    echo "You must unset your local::lib environment variables first"
    echo "Edit your ~/.bash_profile or ~/.bashrc and remove any references"
    echo "to local::lib or export PERL*..."
    exit 1
fi


echo " - Building perl environment -"

# get plenv latest
echo " + Cloning latest plenv..."
git clone git://github.com/tokuhirom/plenv.git ~/.plenv

echo " + Updating .bash_profile with plenv bin and perl binary shims..."
PLENV_PATH='export PATH="$HOME/.plenv/bin:$PATH"'
PLENV_INIT='eval "$(plenv init -)"'
echo $PLENV_PATH >> ~/.bash_profile  # add plenv to path
echo $PLENV_INIT >> ~/.bash_profile  # shims and autocomplete

# make the above available for the rest of this script
eval $PLENV_PATH
eval $PLENV_INIT

echo " + Cloning perl-build..."
git clone git://github.com/tokuhirom/Perl-Build.git ~/.plenv/plugins/perl-build/

echo " + Building perl ${PLENV_PERL_VERSION}..."
plenv install $PLENV_PERL_VERSION -Dusethreads

echo " + Switching to $PLENV_PERL_VERSION"
plenv local $PLENV_PERL_VERSION

echo " + Installing cpanminus..."
plenv install-cpanm

echo " + Installing carton..."
cpanm Carton

echo "plenv installation complete!"