How to get MySQL, Ruby, RVM and Rails working on Snow Leopard
Share this on Twitter
For over a year now I refused to upgrade from Leopard to Snow Leopard on Mac OSX. I knew it wouldn’t be a simple straight forward procedure.
So this past Christmas, when I had some time to spare, I took the plunge and of course, as expected, not everything worked after.
It took me a few days to get everything back up and running so I’ve noted down some things below to help any other designers/developers who have still to make the jump.
Backup your development databases
Should go without saying but here’s your reminder anyway. Backup everything.
Specifically, back up your local databases. For handiness, backup/copy your MySQL databases (located under /usr/local/mysql/data) to your desktop. You’ll want to use these shortly after upgrading.
Sidenote: How to open /usr/ in Finder
I’m usually lost when it comes to working in Terminal. I prefer to see folders in Finder.
In case you didn’t know how to locate and open any hidden folders like /usr/ do the following:
- Open Terminal.app
- Type: cd /usr/
- Type: open .
Simple when you know how.
Install/Upgrade to Snow Leopard
Follow the on screen instructions. Should be simple enough and takes a little less than 1 hour.
Go to MySQL.com and download the latest version of MySQL.
Just to confuse you there are a few options. Go for the DMG Archive. You’re most likely looking for the 64-bit but check first to make sure.
Once downloaded, install MySQL (along with the Startup Item and Preference Pane).
Restore your development databases
At this point we have MySQL installed but we don’t have any data.
You want to copy the data folder that we previously backed up into your new MySQL folder.
I found this link helpful from Corey. Restore development databases after Snow Leopard upgrade.
- Turn off MySQL (use the Preference Pane)
- Replace /usr/local/mysql/data with your backed up data folder
- Turn on MySQL
MySQL is nearly all set
At this point I tried one of my PHP sites locally however it didn’t work.
Thanks to Aaron’s solution here, I was able to get it up and running.
- Open Terminal.app
- Type: sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /usr/local/mysql/support-files/mysql.server
- Find the line starting with basedir and datadir and replace with:
- Save the file
- Start MySQL using the System Preferences pane button.
Installing Ruby, rvm and Rails
This is where I got completely lost and wasted a couple of days trying to troubleshoot and get things up and running.
I installed rvm, ruby and the rails gem but couldn’t get any local applications to run for one reason or another (usually some sort of gem problem).
In the end I had to give in and ask for help from the talented Mr David Rice, whose conclusion was to do a clean install.
- Remove RVM
- Remove Ruby
- Install Xcode if you haven’t already done so (p.s. it’s a big ass file)
- Install git, RVM, Ruby and Rails
Hopefully this is you up and running.
Should it be this difficult?
I’m not a developer so I was lost quite a bit along the way. Running commands in Terminal is a task in itself.
It seems to be different for everyone so the process above might not be exactly the same for you. And if you’re a developer you might be saying to yourself “Why did he need to do that?”. Tell me if anything above looks odd.
If someone can create a button that once clicked, installs everything you need (in all the right places) to get a Rails project running locally, that would be great thanks.
Big thanks to David Rice for his help and to all the websites mentioned above. Stackoverflow is your friend in situations like this.
3 Appreciated Comments
Have a comment? Tweet @leemunroe and I'll be glad to respond.