Memo #1: Installing mysql and memcached gems on Mac OS X with MacPorts

Posted by Dmytro Shteflyuk on under Ruby & Rails

I have not posted anything here for a long time. It’s hard to start blogging again, so I will write a short tips and tricks series called “Memo“. Today I’m going to talk about two Ruby gems I’m using in all my Ruby on Rails project: mysql and memcached. Every time I try to install or update those gems on Mac OS X following error occurs:

1
2
3
Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
    ERROR: Failed to build gem native extension.

And then I’m googling on how to install these gems. It’s time simplify my life and post commands here.

Installing the ruby mysql gem on Mac OS X and MacPorts

Installing mysql5 from MacPorts:

1
sudo port install mysql5

Now we can install mysql gem:

1
2
3
4
kpumuk@kpumuk-mbp~: sudo gem install mysql -- --with-mysql-config=/opt/local/bin/mysql_config5
Building native extensions.  This could take a while...
Successfully installed mysql-2.7
1 gem installed

Installing the ruby memcached gem on Mac OS X and MacPorts

First you need to install memcached and libmemcached:

1
sudo port install memcached libmemcached

And then memcached gem:

1
2
3
4
kpumuk@kpumuk-mbp~: sudo env ARCHFLAGS="-arch i386" gem install memcached --no-ri --no-rdoc -- --with-libmemcached-dir=/opt/local
Building native extensions.  This could take a while...
Successfully installed memcached-0.12
1 gem installed

If you have any questions that could be covered in this series — ask me in comments.

One Response to this entry

Subscribe to comments with RSS

said on February 16th, 2009 at 01:24 · Permalink

Полезная заметка, однако она не уберегла меня от плясок с бубном вокруг гема memcached… дело в том, что недавно вышла новая версия libmemcached 0.26 и версия гема 0.14… скомпилить их вместе под леопардом никак не получается… пришлось откатится до 0.25 + 0.12

Comments are closed

Comments for this entry are closed for a while. If you have anything to say – use a contact form. Thank you for your patience.