Since the arrival of Mavericks I thought I would do a fresh install of my dev environment and I thought I would document my steps here.
Mavericks comes with ruby 2.0 out of the box.
$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [universal.x86_64-darwin13]
But I prefer to manage my versions of ruby using rbenv to allow me to have multiple versions and set them locally per project. So I’ll detail my steps for getting this up and running on Mavericks.
Step 1: Install Xcode. This can be found on the App Store.
Note: You can get away with not installing Xcode and instead just install the Command Line Tools. These can be installed by downloading them from the Apple Developer site. But I need Xcode for other development projects so I’m just going with that.
At this point it might help to check the GCC compiler version your system is referencing. Mine looks like this:
$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Thread model: posix
Step2. Install Homebrew.
Following the websites instructions:
$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
$ brew doctor to ensure that Homebrew is installed correctly and is ready to go.
Step 3: Install GCC.
I need to install ruby 1.8 as I have a couple of legacy apps (I know these need updating and they are on the todo list!) but Xcode and Command Line Tools come with LLVM (as seen above) which won’t compile anything before ruby 1.9.3 so we’ll need to grab GCC from Homebrew.
$ brew tap homebrew/dupes (repository for duplicate system tools)
$ brew install apple-gcc42
Step 4: Install rbenv.
$ brew install rbenv ruby-build
eval "$(rbenv init -)" to your shell profile and restart your shell.
Step 5: Install Ruby.
This is what I have found works for the various versions of ruby I require.
$ CONFIGURE_OPTS="--with-openssl-dir=`brew --prefix openssl` --without-tcl --without-tk" rbenv install 1.8.7-p374
$ CONFIGURE_OPTS="--with-openssl-dir=`brew --prefix openssl` --without-tcl --without-tk" rbenv install 1.9.3-p448
$ rbenv install 2.0.0-p247
Now my list looks like this:
$ rbenv versions
* system (set by /Users/username/.rbenv/version)
To test that everything is working in rbenv land you can do the following:
$ rbenv global 2.0.0-p247
$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin13.0.0]
$ rbenv versions
* 2.0.0-p247 (set by /Users/username/.rbenv/version)
Step 6: Install Database
I’ve had issues in the past and now installing MySQL via Homebrew so I generally download directly from the MySQL site. In the past they have had some packaging issues themselves, leaving out crucial files in the package that required profile hacks to get everything working but thankfully they now seem to be solved.
You can download the version that is marked “Mac OS X 10.7 (x86, 64-bit), DMG Archive” this works fine on OS X Mavericks 10.9. In the download process ignore the login /sign up and scroll down to see the “No thanks, just start my download” and click that link.
The package contains 3 files. The DMG which sets up the DB Server, a pref pane to enable you to start/stop and view the status of MySQL on your system and a startup script installer so MySQL will automatically start on logon. I install all 3 in that order and everything is working fine.
For PostgreSQL and MongoDB you can go directly to their site or Homebrew has some packages for them as well.
If you find (like I did) that you have ann issue with the mysql2 gem and see an error message like this when starting a rails server:
Library not loaded: libmysqlclient.18.dylib
You can solve this by running:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
That’s it… Now it’s all up and running.