Skip to content

Instantly share code, notes, and snippets.

@IdoBar
Forked from revmischa/install-plenv.sh
Last active August 31, 2021 11:28
Show Gist options
  • Save IdoBar/8696b21c589b4016872f3da41ac8dace to your computer and use it in GitHub Desktop.
Save IdoBar/8696b21c589b4016872f3da41ac8dace to your computer and use it in GitHub Desktop.
Set up plenv, install perl, cpanm, carton, set up environment
#!/bin/bash
# installs plenv, perl, carton, cpanminus, sets up environment in .bash_profile or .profile
# from https://github.com/tokuhirom/plenv#readme
MY_PROFILE_FILE="$HOME/.profile"
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
APP_GIT=`which git 2> /dev/null`
test -x "$APP_GIT" || ( echo "You must have git installed, please install with 'sudo apt-get install git' (or ask your system admin to install) and re-run script" > /dev/stderr && exit 1 )
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 >> $MY_PROFILE_FILE # add plenv to path
echo $PLENV_INIT >> $MY_PROFILE_FILE # 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/
LATEST_PERL=`plenv install -l | tail -n1`
plenv install -l
read -e -p "Select perl version to install (press enter for the latest, or replace it from the list above): " -i "$LATEST_PERL" PLENV_PERL_VERSION
# To install the latest version uncomment the line below
# PLENV_PERL_VERSION=`plenv install -l | tail -n1`
echo " + Building perl ${PLENV_PERL_VERSION} (with threading support)..."
plenv install $PLENV_PERL_VERSION -Dusethreads
echo " + Switching to $PLENV_PERL_VERSION"
plenv global $PLENV_PERL_VERSION
echo " + Installing cpanminus..."
plenv install-cpanm
echo " + Installing carton..."
cpanm Carton
echo "plenv installation complete!"
@IdoBar
Copy link
Author

IdoBar commented May 10, 2017

Let the user choose version (with the latest available one as default)

@IdoBar
Copy link
Author

IdoBar commented Feb 5, 2018

Updated user profile path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment