Here's the error I get when I run gem install pg
:
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20151004-5579-1t2l557.rb extconf.rb
checking for pg_config... yes
Using config values from /usr/local/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** extconf.rb failed ***
If I run brew install postgres
I get:
Warning: postgresql-9.4.4 already installed
Likewise, gem list
shows pg (0.18.3)
and a simple gem -v pg
gives:
2.4.4
Running sudo ARCHFLAGS="-arch x86_64" gem install pg
returns:
Building native extensions. This could take a while...
Successfully installed pg-0.18.3
invalid options: -f fivefish
(invalid options are ignored)
Parsing documentation for pg-0.18.3
Done installing documentation for pg after 4 seconds
1 gem installed
But bundle install
throws up this error:
An error occurred while installing pg (0.18.3), and Bundler cannot continue.
Make sure that `gem install pg -v '0.18.3'` succeeds before bundling.
I'm seeing this in mkmf.log
, which I think could be the biggest clue:
ld: warning: ignoring file /opt/local/lib/postgresql93/libpq.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/postgresql93/libpq.dylib
Undefined symbols for architecture i386:
"_PQconnectdb", referenced from:
_t in conftest-fc6c12.o
ld: symbol(s) not found for architecture i386
Which is strange given file /opt/local/lib/postgresql93/libpq.dylib
returns x86_64, not i386:
/opt/local/lib/postgresql93/libpq.dylib: Mach-O 64-bit dynamically linked shared library x86_64
This didn't work either:
sudo env ARCHFLAGS="-arch i386 -arch x86_64" gem install pg