Search code examples
ruby-on-railsrubymakefilerubygemsosx-mountain-lion

Could not create Makefile when installing ruby gems


I'm running OSX 10.8.2, Xcode installed with command line tools.

I'm trying to bundle, and on some gems (I'll specify at the bottom) I am getting the following:

ERROR: Failed to build gem native extension

...

Could not create Makefile due to some reason

So far I get the error on the gem 'pg' and gem 'binding_of_caller'

I believe the error has something to do with the inability to create Makefile, but can't find anything helpful to solve the error. I've pasted the full error below:

I'm at a loss for what to do.

Gem::Installer::ExtensionBuildError: 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/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/1.8/usr/bin/ruby
--with-pg
--without-pg
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
--with-pqlib
--without-pqlib
--with-libpqlib
--without-libpqlib
--with-ms/libpqlib
--without-ms/libpqlib


Gem files will remain installed in /Users/ericavirtue/.bundler/tmp/75812/gems/pg-0.14.1 for inspection.
Results logged to /Users/ericavirtue/.bundler/tmp/75812/gems/pg-0.14.1/ext/gem_make.out
An error occurred while installing pg (0.14.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.14.1'` succeeds before bundling.

EDIT: I'm using rbenv to manage ruby versions and it says I am running 1.9.3 -p385The system ruby is an older version, but that shouldn't matter as far as I know.

I have postgresql installed via homebrew

EDIT 2:

I tried switching to RVM for ruby management, but get another make error:

Error running 'make -j2', please read ... ruby-1.9.3-p385/make.log
There has been an error while running make. Halting the installation.

The file make.log doesn't exist ...


Solution

  • You need to install postgres. From http://deveiate.org/code/pg/README_rdoc.html you need:

    • Ruby 1.8.7-p249 or 1.9.3-p0.
    • PostgreSQL 8.3.x (with headers, -dev packages, etc).

    if you're using brew, just

    brew install postgresql
    

    As far as binding_of_caller, what version of ruby are you using?