Last active
December 31, 2015 23:19
-
-
Save lonefreak/8058952 to your computer and use it in GitHub Desktop.
Installing RBenv with ruby-build plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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