title: "Failed to install gems via Bundler" when deploying to Heroku
body: <p>Background: I'm working through the book "Ruby on Rails 3 Tutorial" by Michael Hartl. I've gotten to the point where I'm setting up heroku. The text directs me to use sqlite3, but it seems that heroku no longer allows a sqlite3 backend. So, I'm trying to use postgres instead.</p>
  
  <p>I'm working on a Mac, OS 10.6.8. </p>
  
  <p>Problem: I try to do </p>
  
  <pre><code>$ git push heroku master
  </code></pre>
  
  <p>Then I get</p>
  
  <pre><code>Counting objects: 69, done.
  Delta compression using up to 2 threads.
  Compressing objects: 100% (55/55), done.
  Writing objects: 100% (69/69), 26.69 KiB, done.
  Total 69 (delta 5), reused 0 (delta 0)
  
  -----&gt; Heroku receiving push
  -----&gt; Ruby/Rails app detected
  -----&gt; Installing dependencies using Bundler version 1.2.0.rc.2
         Running: bundle install --without development:test --path vendor/bundle --    binstubs bin/ --deployment
         You are trying to install in deployment mode after changing
         your Gemfile. Run `bundle install` elsewhere and add the
         updated Gemfile.lock to version control.
         You have added to the Gemfile:
         * pg
         You have deleted from the Gemfile:
         * sqlite3
   !
   !     Failed to install gems via Bundler.
   !
   !     Heroku push rejected, failed to compile Ruby/rails app
  </code></pre>
  
  <p>With respect to "Run 'bundle install' elsewhere" -- what does elsewhere mean in this case? In another directory? I've tried that, to no avail. Also there's no Gemfile.lock file to add. In summary: I'm confused.</p>
  
  <p>======</p>
  
  <p>In response to hgmnz:</p>
  
  <pre><code>$ bundle install
  Fetching gem metadata from https://rubygems.org/.........
  Enter your password to install the bundled RubyGems to your system: 
  ( --- edited out ---)
  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 /sw/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:
  ( -- edited out --- )
  
  
  Gem files will remain installed in /Users/adamshaw/.bundler/tmp/14373/gems/pg-0.14.0 for   inspection.
  Results logged to /Users/adamshaw/.bundler/tmp/14373/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>Then</p>
  
  <pre><code>$ sudo gem install pg -v '0.14.0'
  </code></pre>
  
  <p>Then</p>
  
  <pre><code>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 /sw/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:
  ( --- edited out --- )
  
  Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/pg-0.14.0 for inspection.
  Results logged to /Library/Ruby/Gems/1.8/gems/pg-0.14.0/ext/gem_make.out
  </code></pre>