Skip to content

Instantly share code, notes, and snippets.

@lonefreak
Last active December 31, 2015 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lonefreak/8058952 to your computer and use it in GitHub Desktop.
Save lonefreak/8058952 to your computer and use it in GitHub Desktop.
Installing RBenv with ruby-build plugin
#!/bin/bash
####################################################################
# Script based on three references:
# https://github.com/sstephenson/rbenv
# https://github.com/sstephenson/ruby-build
# https://gist.github.com/jpfuentes2/2002954
####################################################################
# Run this script as a commom user (no need to 'sudo' it)
# However you will need to install these requirements before run this
#
# gcc-c++ patch readline readline-devel zlib zlib-devel
# libyaml-devel libffi-devel openssl-devel make bzip2 autoconf
# automake libtool bison iconv-devel git-core
####################################################################
# Check if rbenv is already installed
command -v rbenv >/dev/null 2>&1 && { echo "RBenv already installed. Get out of here ;)"; exit 0; }
# Check if Git is installed
command -v git >/dev/null 2>&1 || { echo >&2 "Error: Git not found. Install git first."; exit 1; }
# Installing RBenv
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
# Checking if RBenv instalation went well
if [ $? -gt 0 ]; then
echo >&2 "Error: Git clone went wrong!";
exit 1;
fi
# Altering your PATH
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
. ~/.bashrc
# Installing as an rbenv plugin (recommended)
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
# Checking if ruby-build instalation went well
if [ $? -gt 0 ]; then
echo >&2 "Error: ruby-build instalation went wrong!";
exit 1;
fi
# Testing instalation
type rbenv >/dev/null 2>&1 || { echo >&2 "Something went wrong with this instalation, please refer back to the reference URLs"; exit 1; }
echo "####################################################################"
echo "RBenv installed successfuly. Run 'rbenv' to see available actions"
echo "####################################################################"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment