The EnterpriseDB installer for PostgreSQL 9.3 places its files in /Library/PostgreSQL/9.3/*
on Mac OSX. However, the Ruby gem 'pg' loads a legacy version of the 'C' dynamic library libpq.5.dylib
from /usr/lib
instead of using the correct version from /Library/PostgreSQL/9.3/lib
. This occurs despite my having installed the gem with
gem install pg -- --with-pg-config=/Library/PostgreSQL/9.3/bin/pg_config
I determined which version of libpq.5.dylib
is loaded by setting the DYLD_PRINT_LIBRARIES environment variable, prior to requiring the 'pg' gem.
The most obvious consequence of linking to the wrong dynamic library is that the gem fails to connect to the database using a domain socket, because the socket was relocated between versions from /var/pgsql_socket
to /tmp
. However, linking to the old library may also cause other issues.
Any suggestions on how to fix this problem?
(I am running Mac OSX Lion. Additional note: For most pg libraries, the EnterpriseDB installer put both a static (.a) and a dynamic (.dylib) version in /Library/PostgreSQL/9.3/lib
, but for libpq.5
installed only a dynamic version.)