Setting Up a Development Environment on Mountain Lion
This guide covers setting up a development environment on Mountain Lion. It reflects my preferences (Python, Ruby, Go, git, vim) but should be generally useful to anyone wanting to set up after a clean install.
Set up XCode, developer-tools, X11 and gcc according to the instructions at Thoughtbot, which may be found here.
Install brew. Instructions here. You might think you want to use ports to install your libraries, but that’s a Bad Idea. Use brew.
You’ll most likely be asked by OSX to install a Java Developer Update in the middle of your brew install process. This is silly, but do it anyway. (You’ll save yourself pain in the future.)
At the end of the brew installation process, you’ll be asked to edit your paths. Do it. Remember that
brew doctor is your friend.
brew install git
Once that’s done, you’ll want to set up your programming languages. For me that’s Python, Ruby and Go.
You’ll want to do two things: use the latest production version of Python (as of writing, 2.7.3 - I’m assuming you’re like most people and you don’t use Python 3) and you want to set up pip and virtualenv.
Follow the instructions in this guide to use the latest version of Python. Remember to use the
The guide also contains instructions for installing numpy, scipy, matplotlib and IPython, but I generally only install Python (and PyPy, but that’s a separate issue entirely).
For pip, run
And then install virtualenv with
pip install virtualenv
If you do NLP, remember to install NLTK and associated libraries.
This has become surprisingly easy for OSX. It used to be, pre-version 1.0, that you had to compile from source. This is no longer the case. The recommended way to install Go for OSX is to download and run a package file.
You’ll probably want to set up your development tools next. I use vim, so for me this was as simple as copying over my whole
.vim folder and
.vimrc file to my home directory. Also copy your
.ssh folder from your old OSX backups (duh), create
usr/local/bin (because Mountain Lion doesn’t - gasp! - have this directory by default) and remember to copy any other custom scripts you may have written into aforementioned
I recommend skimming through Mathias Bynen’s dotfiles and picking a few settings to use. In particular, I recommend enabling the 2D Dock:
defaults write com.apple.dock no-glass -bool true
and speeding up Mission Control animations (to 0.15, which I find is better than the 0.1 he recommends):
defaults write com.apple.dock expose-animation-duration -float 0.15
Remember you can only see these changes after you run
This is where things get painful. It’s not too hard once you’ve done it, but Mountain Lion (like Lion before it) has done some things that will give you a lot of pain if you don’t know any better. Most of these things are stupid, non-obvious Apply defaults that you’ll have to work around.
A note before we begin: Victor Neo pointed out to me that the Heroku-released Postgres.app is a plug-and-play solution for getting Postgres working on your Mac. And he’s right. But if you’re a masochist (like me), here are instructions for setting things up.
Update (11 August 2012): the issue with installing postgres is now fixed, you may run
brew install postgresql with no workarounds. Your mileage may vary w/r/t the sockets problem. Also, you may also need to increase the kernel shared memory size for Postgresql; instructions here.
brew install postgresql --without-ossp-uuid
This is a workaround, not a fix. There are problems installing postgres on Mountain Lion with ossp-uuid, but after spending an $%&^* amount of time reading long issues threads, I’ve concluded that there’s no good way around this apart from installing with the above flag. If you’ve found a proper fix, though, I’m all ears. Feel free to email me.
Once postgresql finishes installing, follow the instructions brew throws your way. In particular:
initdb /usr/local/var/postgres mkdir -p ~/Library/LaunchAgents cp /usr/local/Cellar/postgresql/9.1.4/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Then manually start the database with:
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
Update (11 August 2012): the socket issue should no longer be a problem, but I’m leaving this in here in case you have similar issues. Next, you may need to fix Mountain Lion’s genius behaviour to have postgres open a socket in
/var/pgsql_socket_alt, which nobody looks at. Create the directory
/var/pgsql_socket, chown it to yourself, and then set the
unix_socket_directory in postgresql.conf.
In terms of terminal commands:
mkdir /var/pgsql_socket sudo chown $USER /var/pgsql_socket
/usr/local/var/postgres/postgresql.conf in a text editor, and uncomment + edit the
unix_socket_directory key to:
unix_socket_directory = '/var/pgsql_socket'
brew install mysql and follow the post installation instructions. No problems there.
And you’re done!