Getting Ruby on Rails & mysql setup on a Mac OSX Leopard clean install
So Rails is already installed on Leopard but you'll probably want to update it to the latest version. So first you need to install the make tools from your Leopard disc:
Leopard CD > Optional Installs > Xcode Tools > XcodeTools.mpkg
Update Rails and all the other gems:
sudo gem update --include-dependencies
Now for mysql. You can download a pre-built package from their site http://dev.mysql.com/downloads/mysql/5.0.html#macosx-dmg
Note that you don't have to register - you can skip past it using the link after the form.
The start up package doesn't work (at the time of writing). However, I found a work around. I'll include the instructions here as well:
First download this MySQL launchd configuration file
sudo mv Downloads/com.mysql.mysqld.plist /Library/LaunchDaemons/
sudo chown root /Library/LaunchDaemons/com.mysql.mysqld.plist
sudo chown -R mysql /usr/local/mysql-5.0.51a-osx10.5-x86/ /usr/local/mysql
sudo launchctl load /Library/LaunchDaemons/com.mysql.mysqld.plist
To allow you to just type 'mysql' from the command line:
vi ~/.bash_profile
Enter the following into the file
export PATH="$PATH:/usr/local/mysql/bin"
Restart terminal and mysql is all setup and will start every time you reboot.
DHH recommends you install the mysql C bindings like thus:
sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Job done!
Leopard comes with mongrel and svn and lots of other goodies out of the box! Have a look with:
gem list
About
Paul is a web developer for Kyanmedia web agency. He's lucky enough to write in Ruby on Rails full-time and uses this site to post snippets of code.
Contact
my name at gmail.com
More snippets
Take a look in the archive
Need a website?
Contact my employer. Make sure to check out our portfolio of work.
Hosting
I recommend hostingrails.com
12 comments made
I seem to be getting the following error when i try to install the C bindings :S
I installed the 64bit version (both the package and the startup item) and changed one of the paths in the commands you mentioned to accommodate this. Everything has worked except this command :((
It ran fine for me.
Here’s a full explanation of the that line. If it helps?
Thanks, Paul! Turns out it was just a proxy/firewall issue. I’ve just got back home and run the script once more – works perfect now :)
Cheers!
Thanks for the tips, however there should be a word of caution as the above methods will lead to an “edge” installation of rails (I got version 2.0.2.9216) which caused a lot of incompatibility grief. In that event, I had to extirpate 2.0.2.9216 and install instead, rails 2.0.2 the stable version. Keep it up!
Strange… when I did it I just got version 2.0.2
Probably 2.0.2 was the “edge” version at that point in time at the repository when you wrote the script.
I just ran ‘gem update—include-dependencies’ again and Rails was not updated to the edge release. My version remained at 2.0.2
I always understood that the gems system was for public releases.
Hi Paul, We might be both right :-) It may be at some stage in the recent past gem was problematic and was dishing out 2.0.2.9216 instead?
See here and here
Also google “gem problem 2.0.2.9216” to see fallout.
The important thing is to verify the gem list using:
gem list --localIf someone have rails 2.02.9216 and not wanting to run “edge” then recovery via something like terminal session below:
That would explain it!
Thanks for clearing that up kuang. Appreciate it.
Hey mate,
Just to let you know that the MySQL package i downloaded was in fact:
mysql-5.0.51b-osx10.5-x86
and not…
mysql-5.0.51a-osx10.5-x86
This stumped me for a few minutes when trying to run:
sudo chown -R mysql /usr/local/mysql-5.0.51a-osx10.5-x86/ /usr/local/mysql
Perhaps something for other people to look out for.
Hi Paul
when i write
$ sudo gem update
i see this error message: <quote> Updating installed gems Updating actionmailer ERROR: While executing gem … (Gem::InstallError) invalid gem format for /Library/Ruby/Gems/1.8/cache/activesupport-2.1.0.gem </quote>how can i solve this problem?
Nice write up, worked like a charm!
Got something to say?