Created
October 25, 2011 17:40
-
-
Save jphenow/1313611 to your computer and use it in GitHub Desktop.
Setup RVM, install ruby 1.9.2, setup default gemset and install Rails 3.1.1 and Bundler
This file contains 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 | |
# | |
# This script is for settingup a usable rvm environment for ruby development | |
# Enables user to manage versions of ruby and sets of Gems in a clean manner | |
# | |
# Information on rvm is available at http://beginrescueend.com/ | |
git="git" | |
rvm="rvm" | |
rvmdir="$HOME/.rvm" | |
if [[ -d "${rvmdir}" ]]; then | |
read -p "WARNING: Removing any current ~/.rvm Okay? (y/n): " | |
[ "$REPLY" == "y" ] && echo "Continuing..." || { echo "Okay, exitting then..."; exit 1; } | |
rm -rf ~/.rvm | |
echo "" | |
fi | |
command -v $git >/dev/null && echo "$git found, good to go" || { echo "$git not found, required to continue. \n Please install $git"; exit 1; } | |
bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer ) | |
# ATTENTION if your .bash_profile is not sourced by default on new bash session either change file or make sure its loaded | |
echo "Adding rvm command to your bash_profile" | |
type -P $rvm &>/dev/null && echo "rvm already found in PATH moving on..." || { echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bashrc; echo "Added to your bashrc" } | |
echo "" | |
echo "Attempting to source our new command (rvm)" | |
source $HOME/.rvm/scripts/rvm | |
# Should output => rvm is a function | |
# If there is an issue here its likely there was an issue loading our command | |
# otherwise check that ~/.rvm was successfully created | |
# May want to follow this script by hand if having issues down here | |
type -P $rvm &>/dev/null && echo "New $rvm command found! Moving on..." || { echo "Can't access $rvm command"; exit 1; } | |
# TODO Want to check `rvm requirements` - will need to see if there is much in the way | |
# of exit statuses for the command before attempting | |
#rvm requirements #To ensure dependencies are met | |
# Install a Ruby version | |
echo "Attempting to install Ruby 1.9.2 and our default gem..." | |
rvm install 1.9.2 | |
# Set as the version we're using | |
echo "" | |
echo "Setting 1.9.2 as default..." | |
rvm use 1.9.2 --default | |
# Create a sandbox for Gems | |
echo "" | |
echo "Creating default gemset (rails31)" | |
rvm gemset create rails31 | |
# Add our Ruby version to the gemset | |
echo "" | |
echo "Adding to a new default gemset (rails31)" | |
rvm 1.9.2@rails31 --default | |
# Install two important, common gems | |
echo "" | |
echo "Installing Rails 3.1.1 and Bundler to our gemset" | |
gem install rails -v 3.1.1 | |
# Top it off | |
echo "That should do it, now you can:" | |
echo -e "\t* Download a project and run 'bundle install' and start working with it" | |
echo -e "\t* Run 'rails new [appname]; cd [appname]; bundle install' and experiment" | |
echo -e "\t* Checkout http://ruby.learncodethehardway.org/book/ if you need to learn Ruby first" | |
echo "You'll likely want to either run 'source ~/.bashrc' now or exit your terminal and open it again" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment