Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
137 lines (77 sloc) 3.81 KB
#!/usr/bin/env bash
# Author: Wayne E. Seguin <>
# Licence: MIT
# This script when sourced will bootstrap a Rails development environment
# on Linux and OSX
# Source this file so that it will leave you in the Sites directory.
if [[ $(id | sed -e 's/(.*//' | awk -F= '{print $2}') -eq 0 ]] ; then
printf "ERROR: This script may not be sourced as the root user."
if [[ ! -d "$sites_path" ]]; then
mkdir -p "$sites_path"
cd "$sites_path"
printf "#\n# Bootstrapping a Rails development environment!\n#\n"
if [[ "Linux" = "$(uname)" ]]; then
printf "#\n# Ensuring OS packges are installed, you will be prompted for your password.\n#\n"
if command -v aptitude || command -v apt-get ; then
sudo aptitude install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev
elif command -v pacman ; then
sudo pacman -S --noconfirm gcc patch curl bison zlib readline libxml2 libxslt git autoconf diffutils patch bison make
elif command -v yum ; then
sudo yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel
sudo yum install -y iconv-devel >/dev/null 2>&1 # NOTE: For centos 5.4 final iconv-devel might not be available :(
elif [[ "Darwin" = "$(uname)" ]]; then
if [[ ! -s /Library/Developer/Shared/XcodeTools.plist ]]; then
printf "Please Install XCode Tools before sourcing this environment bootstrap script."
if ! abort ; then
printf "Ensuring that git is installed...\n"
if command -v git ; then
printf "Found git! Moving right along.\n"
printf "=> Installing Git (git command not found)"
curl -L -o gitinstall
chmod +x "$PWD/gitinstall"
sudo bash "$PWD/gitinstall"
[[ -f gitinstall ]] && rm -f gitinstall
printf "=> Installing RVM the Ruby enVironment Manager\n\n"
curl -O -L
chmod +x rvm-install-head
[[ -f rvm-install-head ]] && rm -f rvm-install-head
printf "=> Setting up RVM to load with new shells.\n"
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*' >> "$HOME/.bash_profile"
printf "=> Loading RVM"
source ~/.rvm/scripts/rvm
printf "=> Installing Ruby 1.8.7\n More information about installing rubies can be found at"
rvm install $ruby_version
printf "=> Using 1.8.7 and setting it as default for new shells\n More information about Rubies can be found at\n"
rvm use $ruby_version --default
printf "=> Installing Rails 3 to the default gemset.\n More information about gemsets can be found at\n"
gem install rails --no-rdoc --no-ri
printf "=> Installing Bundler to the global gemset.\n\n"
rvm gemset use global
gem install bundler --no-rdoc --no-ri
rvm gemset clear
printf "=> Installing the sqlite3 Gem.\n\n"
gem install sqlite3 --no-rdoc --no-ri
printf "\nRails development environment bootstrapped, please enjoy Rails!\n"
printf "\n ~Wayne E. Seguin <>\n"
printf "P.S. You should now be able to generate a new Rails Application in ~/Sites with the command 'rails new <name>'\n"
unset ruby_version rails_version sites_path
Jump to Line
Something went wrong with that request. Please try again.