title: 'Could not find pg-0.12.2 in any of the sources' when running rspec
body: <p>I'm working on building the twitter clone app in Hartl's Rails Tutorial. I cloned my git repo (<a href="https://github.com/stewartmccoy/rails_tutorial">https://github.com/stewartmccoy/rails_tutorial</a>) and put code on to my personal computer, which had previously been on my work computer. So, my developer environment might be slightly different than what's specified in my Gemfile. </p>
  
  <p>My environment:
  Mac OS 10.6.8
  Rails 3.2.13
  ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-darwin10.8.0]</p>
  
  <p><strong>* LOCAL GEMS *</strong></p>
  
  <ul>
  <li>actionmailer (3.2.13, 3.2.11, 3.2.1)</li>
  <li>actionpack (3.2.13, 3.2.11, 3.2.1)</li>
  <li>activemodel (3.2.13, 3.2.11, 3.2.1)</li>
  <li>activerecord (3.2.13, 3.2.11, 3.2.1)</li>
  <li>activeresource (3.2.13, 3.2.11, 3.2.1)</li>
  <li>activesupport (3.2.13, 3.2.11, 3.2.1)</li>
  <li>addressable (2.3.2)</li>
  <li>annotate (2.5.0)</li>
  <li>arel (3.0.2)</li>
  <li>bcrypt-ruby (3.0.1)</li>
  <li>bigdecimal (1.1.0)</li>
  <li>bootstrap-sass (2.1.0.0)</li>
  <li>bootstrap-will_paginate (0.0.6)</li>
  <li>builder (3.0.4)</li>
  <li>bundler (1.3.4)</li>
  <li>capybara (2.0.2, 1.1.2)</li>
  <li>childprocess (0.3.9, 0.3.6)</li>
  <li>coffee-rails (3.2.2)</li>
  <li>coffee-script (2.2.0)</li>
  <li>coffee-script-source (1.6.2, 1.6.1, 1.4.0)</li>
  <li>cucumber (1.2.1)</li>
  <li>cucumber-rails (1.2.1)</li>
  <li>database_cleaner (0.7.0)</li>
  <li>diff-lcs (1.2.1, 1.1.3)</li>
  <li>erubis (2.7.0)</li>
  <li>execjs (1.4.0)</li>
  <li>factory_girl (4.1.0)</li>
  <li>factory_girl_rails (4.1.0)</li>
  <li>faker (1.0.1)</li>
  <li>ffi (1.4.0, 1.3.1)</li>
  <li>gherkin (2.11.5)</li>
  <li>hike (1.2.1)</li>
  <li>i18n (0.6.1)</li>
  <li>io-console (0.3)</li>
  <li>journey (1.0.4)</li>
  <li>jquery-rails (2.2.1, 2.1.4, 2.0.2)</li>
  <li>json (1.7.7, 1.7.6, 1.7.5, 1.5.5)</li>
  <li>libwebsocket (0.1.7.1)</li>
  <li>mail (2.5.3, 2.4.4)</li>
  <li>mime-types (1.21, 1.19)</li>
  <li>minitest (2.5.1)</li>
  <li>multi_json (1.7.1, 1.5.0)</li>
  <li>nokogiri (1.5.8, 1.5.7, 1.5.6)</li>
  <li>pg (0.14.1)</li>
  <li>polyglot (0.3.3)</li>
  <li>rack (1.4.5, 1.4.4, 1.4.1)</li>
  <li>rack-cache (1.2)</li>
  <li>rack-ssl (1.3.3, 1.3.2)</li>
  <li>rack-test (0.6.2)</li>
  <li>rails (3.2.13, 3.2.1)</li>
  <li>railties (3.2.13, 3.2.11, 3.2.1)</li>
  <li>rake (10.0.3, 0.9.2.2)</li>
  <li>rdoc (3.12.2, 3.12, 3.9.5)</li>
  <li>rspec-core (2.13.1)</li>
  <li>rspec-expectations (2.13.0)</li>
  <li>rspec-mocks (2.13.0)</li>
  <li>rspec-rails (2.13.0)</li>
  <li>rubygems-bundler (1.1.1)</li>
  <li>rubyzip (0.9.9)</li>
  <li>rvm (1.11.3.6)</li>
  <li>sass (3.2.7, 3.2.4)</li>
  <li>sass-rails (3.2.6, 3.2.5)</li>
  <li>selenium-webdriver (2.31.0, 2.27.2)</li>
  <li>sprockets (2.2.2, 2.1.3)</li>
  <li>sqlite3 (1.3.7)</li>
  <li>thor (0.17.0, 0.16.0, 0.14.6)</li>
  <li>tilt (1.3.6, 1.3.3)</li>
  <li>treetop (1.4.12)</li>
  <li>tzinfo (0.3.37, 0.3.35)</li>
  <li>uglifier (1.3.0)</li>
  <li>websocket (1.0.7, 1.0.6)</li>
  <li>will_paginate (3.0.3)</li>
  <li>xpath (1.0.0, 0.1.4)</li>
  </ul>
  
  <p>My Gemfile:</p>
  
  <pre><code>source 'https://rubygems.org'
  
  gem 'rails', '3.2.11'
  gem 'bootstrap-sass', '2.1'
  gem 'bcrypt-ruby', '3.0.1'
  gem 'faker', '1.0.1'
  gem 'will_paginate', '3.0.3'
  gem 'bootstrap-will_paginate', '0.0.6'
  gem 'jquery-rails', '2.0.2'
  
  group :development, :test do
    gem 'sqlite3', '1.3.5'
    gem 'rspec-rails', '2.11.0'
    # gem 'guard-rspec', '1.2.1'
    # gem 'guard-spork', '1.2.0'  
    # gem 'spork', '0.9.2'
  end
  
  group :development do
    gem 'annotate', '2.5.0'
  end
  
  # Gems used only for assets and not required
  # in production environments by default.
  group :assets do
    gem 'sass-rails',   '3.2.5'
    gem 'coffee-rails', '3.2.2'
    gem 'uglifier', '1.2.3'
  end
  
  group :test do
    gem 'capybara', '1.1.2'
    gem 'factory_girl_rails', '4.1.0'
    gem 'cucumber-rails', '1.2.1', :require =&gt; false
    gem 'database_cleaner', '0.7.0'
    # gem 'launchy', '2.1.0'
    # gem 'rb-fsevent', '0.9.1', :require =&gt; false
    # gem 'growl', '1.0.3'
  end
  
  group :production do
    gem 'pg', '0.12.2'
  end
  </code></pre>
  
  <p>Anyway, I'm trying to run the test just after Listing 8.18 (<a href="http://ruby.railstutorial.org/chapters/sign-in-sign-out#sec-reviewing_form_submission">http://ruby.railstutorial.org/chapters/sign-in-sign-out#sec-reviewing_form_submission</a>):</p>
  
  <pre><code>$ bundle exec rspec spec/models/user_spec.rb
  </code></pre>
  
  <p>And I get this error:</p>
  
  <pre><code>Could not find pg-0.12.2 in any of the sources
  Run `bundle install` to install missing gems.
  </code></pre>
  
  <p>So, I run <code>bundle install</code> and and get this error:</p>
  
  <pre><code>Fetching gem metadata from https://rubygems.org/.........
  Fetching gem metadata from https://rubygems.org/..
  Using rake (10.0.3) 
  Using i18n (0.6.1) 
  Using multi_json (1.5.0) 
  Using activesupport (3.2.11) 
  Using builder (3.0.4) 
  Using activemodel (3.2.11) 
  Using erubis (2.7.0) 
  Using journey (1.0.4) 
  Using rack (1.4.4) 
  Using rack-cache (1.2) 
  Using rack-test (0.6.2) 
  Using hike (1.2.1) 
  Using tilt (1.3.3) 
  Using sprockets (2.2.2) 
  Using actionpack (3.2.11) 
  Using mime-types (1.19) 
  Using polyglot (0.3.3) 
  Using treetop (1.4.12) 
  Using mail (2.4.4) 
  Using actionmailer (3.2.11) 
  Using arel (3.0.2) 
  Using tzinfo (0.3.35) 
  Using activerecord (3.2.11) 
  Using activeresource (3.2.11) 
  Using addressable (2.3.2) 
  Using annotate (2.5.0) 
  Using bcrypt-ruby (3.0.1) 
  Using bootstrap-sass (2.1.0.0) 
  Using will_paginate (3.0.3) 
  Using bootstrap-will_paginate (0.0.6) 
  Using nokogiri (1.5.6) 
  Using ffi (1.3.1) 
  Using childprocess (0.3.6) 
  Using websocket (1.0.6) 
  Using libwebsocket (0.1.7.1) 
  Using rubyzip (0.9.9) 
  Using selenium-webdriver (2.27.2) 
  Using xpath (0.1.4) 
  Using capybara (1.1.2) 
  Using coffee-script-source (1.4.0) 
  Using execjs (1.4.0) 
  Using coffee-script (2.2.0) 
  Using rack-ssl (1.3.2) 
  Using json (1.7.6) 
  Using rdoc (3.12) 
  Using thor (0.16.0) 
  Using railties (3.2.11) 
  Using coffee-rails (3.2.2) 
  Using diff-lcs (1.1.3) 
  Using gherkin (2.11.5) 
  Using cucumber (1.2.1) 
  Using cucumber-rails (1.2.1) 
  Using database_cleaner (0.7.0) 
  Using factory_girl (4.1.0) 
  Using factory_girl_rails (4.1.0) 
  Using faker (1.0.1) 
  Using jquery-rails (2.0.2) 
  Installing pg (0.12.2) 
  Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
  
          /Users/stewartmccoy/.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
      --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=/Users/stewartmccoy/.rvm/rubies/ruby-1.9.3-p392/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
  
  
  Gem files will remain installed in /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.12.2 for inspection.
  Results logged to /Users/stewartmccoy/.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.
  </code></pre>
  
  <p>Finally, I tried <code>PATH=$PATH:/Library/PostgreSQL/9.2/bin sudo gem install pg</code> and got:</p>
  
  <pre><code>Password:
  Building native extensions.  This could take a while...
  ERROR:  Error installing pg:
      ERROR: Failed to build gem native extension.
  
          /Users/stewartmccoy/.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
      --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=/Users/stewartmccoy/.rvm/rubies/ruby-1.9.3-p392/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
  
  
  Gem files will remain installed in /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.15.0 for inspection.
  Results logged to /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.15.0/ext/gem_make.out
  </code></pre>
  
  <p>Suggestions? </p>
  
  <p>Thanks so much in advance for your help!</p>