title: An error occurred while installing pg (0.12.2), and Bundler cannot continue
body: <p>I'm following the <a href="http://ruby.railstutorial.org/chapters/static-pages#top" rel="nofollow">Michael Hartl Ruby on Rails Tutorial</a> &amp; there is a part where he is he he instructs you to update your Gemfile to include:</p>
  
  <pre><code>group :production do
    gem 'pg', '0.12.2'
  end
  </code></pre>
  
  <p>And then enter the below commands in your terminal:</p>
  
  <pre><code>bundle update
  bundle install --without production
  </code></pre>
  
  <p>When you run the bundle update command it throws back the below errors.</p>
  
  <pre><code>sample_app:$ bundle update
  Fetching gem metadata from https://rubygems.org/.........
  Fetching gem metadata from https://rubygems.org/..
  Resolving dependencies...
  Using rake (10.0.3) 
  Using i18n (0.6.4) 
  etc
  [omitted lines for brevity]
  etc
  Using railties (3.2.12) 
  Using coffee-rails (3.2.2) 
  Installing diff-lcs (1.1.3) 
  Using jquery-rails (2.0.2) 
  Installing pg (0.12.2) 
  Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
  
          /home/ross/.rvm/rubies/ruby-1.9.3-p392/bin/ruby extconf.rb 
  checking for pg_config... no
  No pg_config... trying anyway. If building fails, please try again with
   --with-pg-config=/path/to/pg_config
  checking for libpq-fe.h... no
  Can't find the 'libpq-fe.h header
  *** 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
      etc
      [omitted lines for brevity]
      etc       
  
  
  
  Gem files will remain installed in /home/ross/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.12.2 for inspection.
  Results logged to /home/ross/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.12.2/ext/gem_make.out
  
  An error occurred while installing pg (0.12.2), and Bundler cannot
  continue.
  Make sure that `gem install pg -v '0.12.2'` succeeds before bundling.
  sample_app:$
  </code></pre>
  
  <p>I was able to overcome this error easily be removing the <code>'pg', '0.12.2'</code> gem from the <strong>Gemfile</strong> &amp; replacing it after running the <code>bundle update</code> command.   This seems to work fine as the <code>'pg', '0.12.2'</code> gem is aslo omitted in the <code>without production</code> flag in the latter <code>bundle install --without production</code>.</p>
  
  <p>The <code>'pg', '0.12.2'</code> gem is only needed for deploying to heroku with the correct database &amp; everything works fine even when I deployed it to heroku but I'm just wondering if this is  an error in the Tutorial or am I missing something bigger here?</p>
  
  <p>It's also annoying to have to remove this <strong>Gem</strong> everytime I run <code>bundle update</code>, is <code>bundle update</code> really that necessary? </p>
  
  <p>Thanks in Advance</p>