Unable to install pg gem: Could not create Makefile due to some reason

Hi All,
While installing postgres gem, getting following error-

#===== ERROR MESSAGE START ===========

Building native extensions. This could take a while…

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/ext/builder.rb:54: warning: Insecure world writable dir /usr/local in PATH, mode 040777

ERROR: Error installing pg:

ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/2.0/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.

Provided configuration options:

--with-opt-dir

--without-opt-dir

--with-opt-include

--without-opt-include=${opt-dir}/include

--with-opt-lib

--without-opt-lib=${opt-dir}/lib

--with-make-prog

--without-make-prog

--srcdir=.

--curdir

--ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby

--with-pg

--without-pg

--with-pg-config

--without-pg-config

--with-pg_config

--without-pg_config

--with-pg-dir

--without-pg-dir

--with-pg-include

--without-pg-include=${pg-dir}/include

--with-pg-lib

--without-pg-lib=${pg-dir}/

--with-pqlib

--without-pqlib

--with-libpqlib

--without-libpqlib

--with-ms/libpqlib

--without-ms/libpqlib

Gem files will remain installed in /Users/apple/.rvm/gems/ruby-2.1.2@learning/gems/pg-0.17.1 for inspection.

Results logged to /Users/apple/.rvm/gems/ruby-2.1.2@learning/gems/pg-0.17.1/ext/gem_make.out

#===== ERROR MESSAGE END ===========

Googled a lot, but could not found any working solution. Could anyone please suggest what should be the resolution?

Here is my gem environment-

#=========== GEM ENVIRONMENT START ==================

RubyGems Environment:

  • RUBYGEMS VERSION: 2.0.14

  • RUBY VERSION: 2.0.0 (2014-02-24 patchlevel 451) [universal.x86_64-darwin13]

  • INSTALLATION DIRECTORY: /Users/apple/.rvm/gems/ruby-2.1.2@learning

  • RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby

  • EXECUTABLE DIRECTORY: /Users/apple/.rvm/gems/ruby-2.1.2@learning/bin

  • RUBYGEMS PLATFORMS:

  • ruby

  • universal-darwin-13

  • GEM PATHS:

  • /Users/apple/.rvm/gems/ruby-2.1.2@learning

  • /Users/apple/.rvm/gems/ruby-2.1.2@global

  • GEM CONFIGURATION:

  • :update_sources => true

  • :verbose => true

  • :backtrace => false

  • :bulk_threshold => 1000

  • REMOTE SOURCES:

  • https://rubygems.org/

#=========== GEM ENVIRONMENT END ==================

I am using OS X 10.9.4

I appreciate any help…

Thanks,

Himanshu Prakash

Make sure libpq-dev package is installed.

Thanks for you reply.

Following has helped me-

Use brew to get postgresql

brew install postgresql

Check you have pg_config in the installed brew. I found mine in

/usr/local/Cellar/postgresql/9.3.3/bin/pg_config

Check via :

$ ls /usr/local/Cellar/postgresql/9.3.3/bin/pg_config

/usr/local/Cellar/postgresql/9.3.3/bin/pg_config

Once done, install the pg gem with

Ref- https://stackoverflow.com/questions/19625487/impossible-to-install-pg-gem-on-my-mac-with-mavericks/22259364#22259364?newreg=657757c5d48a4b6994d4868568d94c4b