public
Last active

a no-nonsense guide to setting up an rbenv based ruby on rails development environment on OSX using homebrew, rbenv, bundler, pow, anvil note: all these commands are to be entered at the terminal

  • Download Gist
gistfile1.sh
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
# get homebrew http://mxcl.github.com/homebrew/
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
 
# remove RVM ruby manager if installed... (credit http://etehtsea.me/migration-from-rvm-to-rbenv)
rvm implode
sudo rm /etc/rvmrc
rm ~/.rvmrc
 
# use homebrew to install rbenv and ruby-build
brew update
brew install rbenv
brew install ruby-build
 
# view available rubies
rbenv install --list
 
# fetch a ruby
rbenv install 1.9.3-p385
 
# bind global
rbenv global 1.9.3-p385
 
# temp load rbenv context
eval "$(rbenv init -)";
 
# install bundler
gem install bundler
 
# reset shims
rbenv rehash
 
# verify version
ruby --version
 
# create ~/.bundle/config and put the following in it to create a default bundle binary compile path as [projectdir]/vendor/bundle/bin:
---
BUNDLE_PATH: vendor/bundle
BUNDLE_BIN: vendor/bundle/bin
 
# Add the following to ~/.bash_profile (create the file if missing):
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
# add some easy terminal alias for bundler calls
alias b="bundle exec"
alias bi="bundle install --without production"
# add bundler binstubs to the path so relative binarys are auto run from a project dir
export PATH="./vendor/bundle/bin:$PATH"
 
# install pow (with apache proxy! so you can work alongside existing apache projects)
https://github.com/37signals/pow/wiki/Running-Pow-with-Apache
 
# install pow util, anvil
http://anvilformac.com/
 
# install rails
rbenv shell 1.9.3-p385
gem install rails
# rebuild global binary proxies
rbenv rehash
 
# now you can cd to your base project folder and create new rails project (optionally with mysql)
rails new projectname --database=mysql
 
# set default rails version for project, creates .rbenv-version
cd projectpath
rbenv local 1.9.3-p385
 
# run bundler install to fetch all the gems
bi
 
# symlink the project directory to ~/.pow
cd ~/.pow
ln -s projectpath
 
# view local app
http://projectpath.dev
 
# add bundler path to .gitignore to stop it uploading chunky binaries
/vendor/bundle
 
# mysql2 gem install may require editing /usr/local/Cellar/mysql/5.XX.XX/bin/mysql_config
cflags="-I$pkgincludedir -Wall -Os -g -fno-strict-aliasing -DDBUG_OFF " #note: end space! removed: -Wno-null-conversion -Wno-unused-private-field
cxxflags="-I$pkgincludedir -Wall -Os -g -fno-strict-aliasing -DDBUG_OFF " #note: end space! removed: -Wno-null-conversion -Wno-unused-private-field

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.