Last Updated: February 25, 2016
·
5.499K
· glebm

Set up a Mac for Ruby Dev

The SSD on my Air died this weekend, no backup.
This time when setting a new system up I took note of all the steps.
All the steps were tested on the latest Mac OS X 10.8.3 (latest).

Apple compiler toolchain

Homebrew

This is a package manager with packages described in ruby.

ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
brew doctor

Read brew doctor output and do what it says if something is wrong!
Some packages you will probably need for ruby dev:

brew install node wget qt4 curl-ca-bundle

Git

Git that comes with Mac is old. Install a better one from brew.

brew install git
# Write settings to ~/.gitconfig
git config --global user.name '{YOUR NAME}'
git config --global user.email {YOUR EMAIL}
# a global git ignore file:
git config --global core.excludesfile '~/.gitignore'    
echo '.DS_Store' >> ~/.gitignore 
# add your IDE files to global config
echo '.idea/*' >> ~/.gitignore 
# use keychain for storing passwords 
git config --global credential.helper osxkeychain
# you might not see colors without this
git config --global color.ui true
# more useful settings: https://github.com/glebm/dotfiles/blob/master/.gitconfig

SCM Breeze shortcuts are great too.

RVM

Ruby version manager (install and auto-switch ruby and gems per-project).

brew install curl-ca-bundle
\curl -L https://get.rvm.io | bash -s head --ruby=2.0.0 --autolibs=enabled

Postgresql

brew install postgres
initdb /usr/local/var/postgres -E utf8
# load on boot:
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
# load now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

Now you can connect to it via psql console:

psql -h 127.0.0.1 postgres

Here is how you can create a user (from psql console):

CREATE USER zuigo WITH PASSWORD 'zuigo';
ALTER USER zuigo CREATEDB;
# To grant superuser
ALTER ROLE zuigo WITH SUPERUSER;

There is also a GUI pg manager helpful for troubleshooting issues http://www.pgadmin.org/download/macosx.php

MySQL

brew install mysql  
ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

Now you can connect to it via mysql console:

mysql -uroot

Here is how you can create a user (from mysql console):

# For every host create a user (or use 'zuigo'@'%'):
CREATE USER 'zuigo'@'localhost' IDENTIFIED BY 'zuigo';
# Grant all privileges for DB names that start with "zuigo"
GRANT ALL PRIVILEGES ON `zuigo%`.* TO 'zuigo'@'localhost';

Redis

Great in-memory data structure store, persistent with expiry times, works with (z-)sets, arrays, hashes, and key-value.

brew install redis
ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist

ZSH

Mac OS X comes with an old bash for a shell. zsh is much better!

brew install zsh
sudo mv /etc/zshenv /etc/zprofile
cat /etc/shells | grep zsh || which zsh | sudo tee -a /etc/shells 
chsh -s $(which zsh)

You'll also want all the magic provided by either zprezto or oh-my-zsh. See my dot files repo for details.

Advanced configuration

I have all my config files in git: https://github.com/glebm/dotfiles/
Then after installing zsh I just do:

rm ~/.gitconfig ~/.viminfo
git clone git@github.com:glebm/dotfiles.git ~/.dotfiles
cd ~/.dotfiles   
./install

That repo is specific to me (e.g. it has user.name set to Gleb Mazovetskiy in .gitconfig etc), but you can fork it or create your own from scratch.

Must-have apps

Also, you can remap your Caps Lock in System Preferences -> Keyboard -> Modifier Keys.

1 Response
Add your response

I also created a whole new working Mac environment, and decided to use babushka for it. The cool thing about babushka is, that it is basically only one step to install everything I need to work on a new machine. And you can share the recipies.

over 1 year ago ·