Skip to content

Instantly share code, notes, and snippets.

@dillera
Last active October 11, 2016 09:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dillera/1927207 to your computer and use it in GitHub Desktop.
Save dillera/1927207 to your computer and use it in GitHub Desktop.
Install rbenv on OSX
# THE README:
# Do these by hand first!
#
# install compiler
## THIS WILL NOT WORK FOR YOU- Change
# wget https://nas.chalybs.net/software/Software/_MacOS/_Apple/command_line_tools_for_xcode_.dmg
# Install brew
# /usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"
# Install XQuartz on ML:
# https://github.com/sstephenson/ruby-build/issues/193
## http://xquartz.macosforge.org/landing/
------ Now you can run this script -------------
#!/bin/bash
set -e # exit on error
### README
export CPPFLAGS=-I/opt/X11/include
# ERROR: This package must be compiled with GCC, but ruby-build couldn't
# find a suitable `gcc` executable on your system. Please install GCC
# and try again.
# This will fix it:
brew tap homebrew/dupes
brew install apple-gcc42
# * installs your desired ruby versions using rbenv
# ** including openssl (needed by bundler)
# ** including sqlite (probably needed for rails apps)
#
# Before you start:
# * put ssh-keys in place
# * $ ssh git@github.com
# * If you're behind a proxy, be sure to set $http_proxy etc!
#
# After the Script has run:
# * reload your .bash_profile
### /README
### CONFIG
# Ruby Versions to install
RBVER192='1.9.2-p290'
RBVER187='1.8.7-p357'
RBVER193='1.9.3-p392'
RBVER_GLOBAL=${RBVER192}
PROFILE=~/.bash_profile
MYPROXY="http://proxy:3128"
### /CONFIG
# Ask for the administrator password upfront
sudo -v
# Keep-alive: update existing `sudo` time stamp until `.osx` has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
# Deal with an HTTP Proxy and git
git config --global http.proxy $MYPROXY
git config --global http.sslverify false
cd
### Install rbenv, setup your profile of choice
test -d ~/.rbenv || git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
# modify $PATH and autoload rbenv
PROFILE=~/.bash_profile grep 'rbenv/bin' $PROFILE &>/dev/null || echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> $PROFILE
PROFILE=~/.bash_profile grep 'rbenv init' $PROFILE &>/dev/null || echo 'eval "$(rbenv init -)"' >> $PROFILE
PROFILE=~/.bash_profile grep 'unset RUBYLIB' $PROFILE &>/dev/null || echo 'unset RUBYLIB' >> $PROFILE
# reload shell
source $PROFILE
###
#
# Install some rbenv plugins
#
###
# Install ruby-build
mkdir -p ~/.rbenv/plugins
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
cd ~/.rbenv/plugins/ruby-build && sudo ./install.sh
# Install rbenv-update
cd ~/.rbenv/plugins
git clone https://github.com/rkh/rbenv-update.git rbenv-update
rbenv rehash
~/.rbenv/plugins/rebenv-update/bin/rbenv-update
echo "Completed rbenv update"
### Install Rubies, 1.8.7, 1.9.2, 1.9.3
rbenv install $RBVER192
rbenv install $RBVER187
rbenv install $RBVER193
# reload binaries
rbenv rehash
# set as default version
rbenv global $RBVER_GLOBAL
ruby -v
# set some defaults
test -s ~/.gemrc || echo 'gem: --no-rdoc --no-ri' >> ~/.gemrc
echo 'Here is your ~/.gemrc:'
cat ~/.gemrc
echo '=== end of .gemrc ==='
# reload shell
source $PROFILE
# install some gems that you love
gem install actionmailer -v=2.3.8
gem install actionpack -v=2.3.8
gem install activesupport -v=2.3.8
gem install highline -v=1.6.1
gem install json -v=1.6.5
gem install mime-types -v=1.16
gem install nokogiri -v=1.4.3.1
gem install rest-client -v=1.6.1
gem install i18n -v=0.6.4
gem install bundler -v=1.2.1
gem install capistrano -v=2.12
rbenv rehash
grep 'BUNDLE_WITHOUT' $PROFILE &>/dev/null || echo 'export BUNDLE_WITHOUT=production' >> $PROFILE
# install the rbenv updater
git clone https://github.com/rkh/rbenv-update.git $RBENV_ROOT/plugins/rbenv-update
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment