Skip to content

Instantly share code, notes, and snippets.

@davidsirr
Last active March 2, 2021 09:07
Show Gist options
  • Save davidsirr/4976499 to your computer and use it in GitHub Desktop.
Save davidsirr/4976499 to your computer and use it in GitHub Desktop.
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
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment