While building a rails app, suddenly got a message that my rails gem was gone, so I re-installed rails completely. Then got this:
An error occurred while installing pg (0.18.2), and Bundler cannot continue.
Make sure that gem install pg -v '0.18.2'
succeeds before bundling.
But running the command gets me this:
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20151014-55380-170ndlh.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 ***
Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options.
I am not sure if this is relevant, but around the time it started happening, my bundler stopped being able to install gem without sudo, which I never needed before.
When I open the mkmf.log file, I get this:
/usr/local/Cellar/postgresql/9.4.5/include/libpq-fe.h:250:1: note: 'PQconnectdb' declared here
extern PGconn *PQconnectdb(const char *conninfo);
^
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <libpq-fe.h>
4:
5: /*top*/
6: extern int t(void);
7: int t(void) { PQconnectdb(); return 0; }
8: int main(int argc, char **argv)
9: {
10: if (argc > 1000000) {
11: printf("%p", &t);
12: }
13:
14: return 0;
15: }
/* end */
--------------------
(the log is longer, but this is the tail part of it that has an error in it).
I tried gem install pg — –with-pg-lib=/usr/lib
, which did not work.
How do I fix this? Thanks!