title: Rails: Error installing pg gem
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/11172264/postgres-the-last-version-0-14-0-of-the-pg-gem-gives-error">Postgres - the last version 0.14.0 of the &ldquo;pg&rdquo; gem gives error</a>  </p>
  </blockquote>
  
  
  
  <p>I'm new to rails. I want to use PostgreSQL since Heroku uses it too, but I'm having a bad time installing the <code>pg</code> gem. Apparently, some files are missing and a Makefile cannot be created?</p>
  
  <p>My gem file looks like this:    </p>
  
  <pre><code>source 'https://rubygems.org'
  
  gem 'rails', '3.2.6'
  gem 'faker', '1.0.1'
  gem 'pg', '0.12.2'
  gem 'json'
  
  group :development, :test do
    gem 'rspec-rails', '2.10.0'
  end
  
  group :assets do
    gem 'sass-rails',   '~&gt; 3.2.3'
    gem 'coffee-rails', '~&gt; 3.2.1'
    gem 'uglifier', '&gt;= 1.0.3'
  end
  
  gem 'jquery-rails', '2.0.0'
  
  group :test do
    gem 'capybara', '1.1.2'
    gem 'factory_girl_rails', '1.4.0'
  end
  </code></pre>
  
  <p>And when I run <code>bundle install</code> I get the following error when installing the pg gem:</p>
  
  <pre><code>    Installing pg (0.14.0) with native extensions 
  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/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/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/KennyGWang/.bundler/tmp/18833/gems/pg-0.14.0 for inspection.
  Results logged to /Users/KennyGWang/.bundler/tmp/18833/gems/pg-0.14.0/ext/gem_make.out
  An error occured while installing pg (0.14.0), and Bundler cannot continue.
  Make sure that `gem install pg -v '0.14.0'` succeeds before bundling.
  </code></pre>
  
  <p>I installed postgresql using homebrew, <code>brew install postgresql</code>, thus <code>which psql</code> gives me <code>/usr/local/bin/psql</code></p>
  
  <p>Any help is appreciated!</p>