Thinking Sphinx with Postgres support on OSX

June 20, 2010

Today I was going through some trouble setting up an existing Rails project I need to do some work on.

The project uses the Postgres database and Sphinx to provide search functionality. Installing Postgres is easy using the official DMG. Installing Sphinx using Homebrew is also very easy:

sudo brew install sphinx

That should be it, right? Unfortunately, not quite. This did install Sphinx, but without Postgres support. If you build TS yourself, Postgres support is enabled by adding the –with-psql option when calling ./configure. I looked through the brew documentation but didn’t find any way of passing this option to the configure command that brew executes.

Finally, it occurred to me to look into the brew “formula” for Sphinx. This is just Ruby code, and the source of the problem was easy to spot: It turns out that the formula installs Postgres support automatically if it detects that Postgres is installed. The problem was the method it used for detecting this:

config_args << “–with-pgsql” if `/usr/bin/which pg_config`.size > 0
So if pg_config had been in my path, it would have worked. But it wasn’t, simply because I hadn’t yet gotten around to adding /Library/PostgreSQL/8.4/bin to my PATH variable.
Did this, reinstalled sphinx, all went well.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: