Skip to content

Getting Ruby on Rails & mysql setup on a Mac OSX Leopard clean install

Posted on 13 April 2008

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

View the snippets archive ››

17 comments made

Scotty commented on 14 Apr 08 at 05:41

I seem to be getting the following error when i try to install the C bindings :S

ERROR:  could not find mysql locally or in a repository

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 :((

Paul commented on 14 Apr 08 at 05:51

It ran fine for me.

Here’s a full explanation of the that line. If it helps?

Scotty commented on 14 Apr 08 at 11:21

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!

kuang commented on 02 May 08 at 23:35

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!

Paul Sturgess commented on 03 May 08 at 03:12

Strange… when I did it I just got version 2.0.2

kuang commented on 03 May 08 at 06:45

Probably 2.0.2 was the “edge” version at that point in time at the repository when you wrote the script.

Paul Sturgess commented on 03 May 08 at 07:27

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.

kuang commented on 03 May 08 at 23:38

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 --local

If someone have rails 2.02.9216 and not wanting to run “edge” then recovery via something like terminal session below:


users-mac-pro:~ user$ gem list --local

*** LOCAL GEMS ***

actionmailer (2.0.2.9216, 2.0.2, 1.3.3)
actionpack (2.0.2.9216, 2.0.2, 1.13.6, 1.13.3)
actionwebservice (1.2.6, 1.2.3)
activerecord (2.0.2.9216, 2.0.2, 1.15.6, 1.15.3)
activeresource (2.0.2.9216, 2.0.2)
activesupport (2.0.2.9216, 2.0.2, 1.4.4, 1.4.2)
acts_as_ferret (0.4.3, 0.4.1)
capistrano (2.2.0, 2.0.0)
cgi_multipart_eof_fix (2.5.0, 2.2)
daemons (1.0.10, 1.0.7)
dnssd (0.6.0)
fastthread (1.0.1, 1.0)
fcgi (0.8.7)
ferret (0.11.6, 0.11.4)
gem_plugin (0.2.3, 0.2.2)
highline (1.4.0, 1.2.9)
hpricot (0.6)
libxml-ruby (0.5.4, 0.3.8.4)
linecache (0.42)
mongrel (1.1.4, 1.0.1)
needle (1.3.0)
net-sftp (1.1.1, 1.1.0)
net-ssh (1.1.2)
rails (2.0.2.9216, 2.0.2, 1.2.3)
rake (0.8.1, 0.7.3)
RedCloth (3.0.4)
ruby-debug-base (0.10.1, 0.10.0)
ruby-debug-ide (0.1.10)
ruby-openid (2.0.4, 1.1.4)
ruby-yadis (0.3.4)
rubygems-update (1.1.1)
rubynode (0.1.5, 0.1.3)
sources (0.0.1)
sqlite3-ruby (1.2.1)
termios (0.9.4)
users-mac-pro:~ user$ sudo gem uninstall rails
Password:

Select gem to uninstall:
 1. rails-1.2.3
 2. rails-2.0.2
 3. rails-2.0.2.9216
 4. All versions
> 3
Successfully uninstalled rails-2.0.2.9216
users-mac-pro:~ user$ sudo gem uninstall actionmailer

Select gem to uninstall:
 1. actionmailer-1.3.3
 2. actionmailer-2.0.2
 3. actionmailer-2.0.2.9216
 4. All versions
> 3
Successfully uninstalled actionmailer-2.0.2.9216
users-mac-pro:~ user$ sudo gem uninstall actionpack

Select gem to uninstall:
 1. actionpack-1.13.3
 2. actionpack-1.13.6
 3. actionpack-2.0.2
 4. actionpack-2.0.2.9216
 5. All versions
> 4
Successfully uninstalled actionpack-2.0.2.9216
users-mac-pro:~ user$ sudo gem uninstall activerecord

Select gem to uninstall:
 1. activerecord-1.15.3
 2. activerecord-1.15.6
 3. activerecord-2.0.2
 4. activerecord-2.0.2.9216
 5. All versions
> 4
Successfully uninstalled activerecord-2.0.2.9216
users-mac-pro:~ user$ sudo gem uninstall activeresource

Select gem to uninstall:
 1. activeresource-2.0.2
 2. activeresource-2.0.2.9216
 3. All versions
> 2
Successfully uninstalled activeresource-2.0.2.9216
users-mac-pro:~ user$ sudo gem install rake
Bulk updating Gem source index for: http://gems.rubyonrails.org/
Successfully installed rake-0.8.1
1 gem installed
Installing ri documentation for rake-0.8.1...
Installing RDoc documentation for rake-0.8.1...
users-mac-pro:~ user$ gem list

*** LOCAL GEMS ***

actionmailer (2.0.2, 1.3.3)
actionpack (2.0.2, 1.13.6, 1.13.3)
actionwebservice (1.2.6, 1.2.3)
activerecord (2.0.2, 1.15.6, 1.15.3)
activeresource (2.0.2)
activesupport (2.0.2.9216, 2.0.2, 1.4.4, 1.4.2)
acts_as_ferret (0.4.3, 0.4.1)
capistrano (2.2.0, 2.0.0)
cgi_multipart_eof_fix (2.5.0, 2.2)
daemons (1.0.10, 1.0.7)
dnssd (0.6.0)
fastthread (1.0.1, 1.0)
fcgi (0.8.7)
ferret (0.11.6, 0.11.4)
gem_plugin (0.2.3, 0.2.2)
highline (1.4.0, 1.2.9)
hpricot (0.6)
libxml-ruby (0.5.4, 0.3.8.4)
linecache (0.42)
mongrel (1.1.4, 1.0.1)
needle (1.3.0)
net-sftp (1.1.1, 1.1.0)
net-ssh (1.1.2)
rails (2.0.2, 1.2.3)
rake (0.8.1, 0.7.3)
RedCloth (3.0.4)
ruby-debug-base (0.10.1, 0.10.0)
ruby-debug-ide (0.1.10)
ruby-openid (2.0.4, 1.1.4)
ruby-yadis (0.3.4)
rubygems-update (1.1.1)
rubynode (0.1.5, 0.1.3)
sources (0.0.1)
sqlite3-ruby (1.2.1)
termios (0.9.4)
users-mac-pro:~ user$ gem list -local
ERROR:  While executing gem ... (OptionParser::InvalidOption)
    invalid option: -ocal
users-mac-pro:~ user$ gem list --local

*** LOCAL GEMS ***

actionmailer (2.0.2, 1.3.3)
actionpack (2.0.2, 1.13.6, 1.13.3)
actionwebservice (1.2.6, 1.2.3)
activerecord (2.0.2, 1.15.6, 1.15.3)
activeresource (2.0.2)
activesupport (2.0.2.9216, 2.0.2, 1.4.4, 1.4.2)
acts_as_ferret (0.4.3, 0.4.1)
capistrano (2.2.0, 2.0.0)
cgi_multipart_eof_fix (2.5.0, 2.2)
daemons (1.0.10, 1.0.7)
dnssd (0.6.0)
fastthread (1.0.1, 1.0)
fcgi (0.8.7)
ferret (0.11.6, 0.11.4)
gem_plugin (0.2.3, 0.2.2)
highline (1.4.0, 1.2.9)
hpricot (0.6)
libxml-ruby (0.5.4, 0.3.8.4)
linecache (0.42)
mongrel (1.1.4, 1.0.1)
needle (1.3.0)
net-sftp (1.1.1, 1.1.0)
net-ssh (1.1.2)
rails (2.0.2, 1.2.3)
rake (0.8.1, 0.7.3)
RedCloth (3.0.4)
ruby-debug-base (0.10.1, 0.10.0)
ruby-debug-ide (0.1.10)
ruby-openid (2.0.4, 1.1.4)
ruby-yadis (0.3.4)
rubygems-update (1.1.1)
rubynode (0.1.5, 0.1.3)
sources (0.0.1)
sqlite3-ruby (1.2.1)
termios (0.9.4)
Paul Sturgess commented on 04 May 08 at 04:17

That would explain it!

Thanks for clearing that up kuang. Appreciate it.

Peter Roome commented on 13 May 08 at 18:23

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.

Mr.Jar commented on 30 Jun 08 at 16:10

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?

Irish commented on 30 Jun 08 at 22:31

Nice write up, worked like a charm!

Dave commented on 08 Jul 08 at 14:52

How do I setup up Apache so that I can use Leopard (not Leopard server)as my production machine.

Thanks.

Yongkun Jeon commented on 15 Jul 08 at 05:43

Totally helpful post.

Thanks Paul!

Ben Strackany commented on 17 Oct 08 at 12:42

Thanks for the steps, very helpful. However, I get an access denied when trying to follow some of the steps — do we have to enable the root user and log in as root first?

Ben Strackany commented on 17 Oct 08 at 12:44

Ah never mind, I overlooked the “sudo” :)

Christian Sueiras commented on 28 Nov 08 at 21:43

I LOVE YOU!!!! THANK YOU OH SO MUCH!!!

Got something to say?

About

Paul is a Rails developer for Kyan web agency.

Checkout his ramblings about music, what he's listening to and his other random thoughts.

He also writes on the Kyan blog.

More snippets

Take a look in the archive

Need a website?

Your best bet is to contact Paul's employer. Make sure to check out the portfolio of work.

Hosting

I recommend hostingrails.com

Contact

my name at gmail.com