30.08.08

Installing Ferret on a PowerPC Mac

Posted in Server stuff and installs at 2:45 am by admin

I am (still) a proud owner of an Apple PowerBook, and it’s only now that in this overwhelmingly x86 world that things are starting to get a little awkward. I dual boot Ubuntu and OS X and as many people know running powerpc linux is full of unexpected trouble and disappointments.

Anyway so I was trying to install ferret (a ruby based full text search engine) through ruby gems (I’m using 1.0.1) and ran into a puzzling issue. It should have been as simple first install the rubygem, then the rails plug-in,

> sudo gem install ferret

> ruby script/plugin install svn://projects.jkraemer.net/acts_as_ferret/tags/ stable/acts_as_ferret 

However the powerpc world is as cruel as it is neglected. Though this command seems to result in success when you try and use the library with your rails app or whatever you will encounter an error when starting the server, something like

Failed to load /usr/local/lib/ruby/gems/1.8/gems/ferret-0.11.6/lib/ferret_ext.bundle (LoadError)

The reason for this is the Makefile that comes with this rubygem has the processor type hardcoded as i386, that’s intel x86 processors. 

The solution: fix the makefile and compile it for your processor in a few easy steps.

Open your terminal and find your gems directory, mine is /usr/local/lib/ruby/gems/1.8/gems/ yours may vary due to 1.8, installation and ruby version.

> cd usr/local/lib/ruby/gems/1.8/gems/ 

Next Dig a little deeper into the ferret gem’s directory (assuming we have the same version it should be something like …

>cd ferret-0.11.6/ext

Delete all the existing binaries, they are of no use to you.

> sudo rm *.o ferret_ext.bundle

Fix that make file. Use your favourite text editor which must be vi right?

> sudo vim Makefile

With the file open type

:%s/i386/ppc

to globally replace i386 with ppc. Next type

:wq

to save and exit. Use something less trciky like textmate, BBEdit or pico if you’re not familiar with vi. On the other hand you could learn to use it before you bring shame upon yourself and your family.

Now we’re ready to recompile the thing, pretty simple!

> sudo make 

This will compile all those little c files in there and create a new ferret_ext.bundle, for some reason this doesn’t really live here so last thing is to move to the right place

> sudo cp ferret_ext.budle ../lib

All done. Start your rails app and go.

Leave a Comment