简体   繁体   中英

Cannot get postgresql gem installed after Mountain Lion install

I have been trying for some time now to get my Rails development environment back up since I upgraded from Lion to Mountain Lion. The problem is specifically installing the pg-0.14.0 (postgresql) gem.

I have tried the instructions on this post but with no luck. I have tried uninstalling Postgres with Homebrew and then reinstalling it. Nothing is working. If I try to install this gem I recieve this error:

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/1.8/usr/bin/ruby 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.

Where can I find mkmf.log ? Can anyone give me a suggestion on how to install the pg gem again?

update I was able to locate my mkmf.log file using :

find / -name mkmf.log 2>/dev/null

There are several failed xcrun calls like the one below:

have_library: checking for PQconnectdb() in -llibpq... -------------------- no

"xcrun cc -o conftest -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/usr/local/Cellar/postgresql/9.1.4/include -arch i386 -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE -fno-common -pipe -fno-common conftest.c -L. -L/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib -L. -arch i386 -arch x86_64 -L/usr/local/Cellar/postgresql/9.1.4/lib -lruby -llibpq -lpthread -ldl -lobjc " ld: library not found for -llibpq clang: error: linker command failed with exit code 1 (use -v to see invocation)

Why am I getting errors when running xcrun? Has anyone seen this?

Thanks!

The error says it right there:

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)

It can't find libpq, or its tests that try to compile a test program and link to it are failing. Since it's finding /usr/local/bin/pg_config it should know where the Pg libraries and headers are, so the problem is probably an error in the test compile.

To learn more you will need to examine mkmf.log . Run

find . -name mkmf.log

from within the directory you ran the gem install command, that'll probably locate it. Update your post with its contents.

I got this resolved finally. I used RVM to uninstall ruby and re-install ruby version 1.9.3. This allowed me to run 'bundle install' without a problem. I checked that all gems where loaded (gem list). However my rails application could not locate the postgres socket file at this point. The same problem is detailed here. Rather than locating the postgresql.conf file, changing permissions on it, and editing it I just uninstalled my current version of Postgres and downloaded the latest One-Click installer from PostGres. When I ran the installer again it detected the other PostGres installation and updated it. This updated the configurations for me and all is well again.

I hope this might help some other poor rails dev upgrading to Mountain Lion :)

I've struggled a few hours with this too and couldn't find anything working in my setup.

I ended up using postgres.app . This is a packaged version of Postgres released by the people at Heroku. They say it's "the easiest way to run postgreSQL on the Mac". Based on my experience, this is true!

Just drop it into you Applications folder and you're done! (I've just had to restart to free port 5432).

Side note: they also have released an application called Induction to manage and query your databases, but for the moment it is unusable in Mountain Lion.

如果你有Mountain Lion和XCODE 4.4.1你没有命令工具go和dowload from https://developer.apple.com/downloads/index.action

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM