2010-12-15

Fresh mac rails development setup - quick and clean

just got a new macbook pro,
logging this here incase I have to do it again soon.
if you have a new mac and you happen to find this blog post soon after I'm posting it, this will save you some time! :)

the sites I used to get help listed here:
https://github.com/mxcl/homebrew/wiki/installation
http://everydayrails.com/2010/06/28/rvm-gemsets-rails3.html
http://blog.theablefew.com/very-simple-homebrew-mysql-and-rails
http://spyrestudios.com/setting-up-a-rails-development-system-on-mac-osx-snow-leopard

exactly what I did, in order, copy and paste these codeblocks:
1. first install xcode(downloaded from the mac dev site)
2. install homebrew:

ruby -e "$(curl -fsSLk https://gist.github.com/raw/323731/install_homebrew.rb)"
3. modify /usr/local permissions:

sudo chown -R $USER /usr/local
curl -Lsf http://github.com/mxcl/homebrew/tarball/master | tar xz --strip 1 -C/usr/local
4.a install RVM
bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
4.b create .bash_profile
touch ~/.bash_profile
4.c add this to ~/.bash_profile
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
5. install ruby 1.8.7(via rvm)
rvm install 1.8.7
6. install ruby 1.9.2(via rvm)
rvm install 1.9.2
7. make rvm's 1.9.2 the system default(and switch to it)
rvm 1.9.2 --default

8.a install mysql
brew install mysql
8.b following instructions printed out after mysql installs: "If this is your first install, automatically load on login with:"
cp /usr/local/Cellar/mysql/5.1.53/com.mysql.mysqld.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/com.mysql.mysqld.plist
mysql_install_db
/usr/local/Cellar/mysql/5.1.53/bin/mysqladmin -u root password 'YOURPASSWORDHERE'
sudo touch /etc/my.cnf
sudo vim /etc/my.cnf
this is what I put there:
[mysqld]
max_allowed_packet=64M
character-set-server = utf8
default-character-set = utf8

[mysql]
default-character-set = utf8

[client]
default-character-set=utf8

I made a default user for mysql client
touch ~/.my.cnf
vim ~/.my.cnf
pasted in this:
[client]
user = root
password = YOURPASSWORDHERE

install rails gem and dependencies(remember this is for the 1.9.2 version of ruby, each version of ruby in rvm has it's own location for gems(and then there's gemsets, which I won't be setting up at the moment)
gem install rails
install mysql gem, and config for mac:
env ARCHFLAGS="-arch x86_64" gem install mysql --no-rdoc --no-ri -- --with-mysql-config=/usr/local/bin/mysql_config

if this is what you do, you can probably pick it up from here