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