title: Issue with the installation of gem 'pg' in Heroku - Rails
body: <p>I'm trying to install ruby on rails on OSX for <a href="https://devcenter.heroku.com/articles/getting-started-with-rails4#write-your-app" rel="nofollow">heroku</a>, for which I used <a href="http://guides.railsgirls.com/install/#setup-for-os-x" rel="nofollow">this tutorial</a>.  It seemed to install fine on the terminal, but after doing </p>
  
  <pre><code>$rails new myapp --database=postgresql
  cd myapp
  </code></pre>
  
  <p>I did this </p>
  
  <pre><code>rails generate controller welcome
  </code></pre>
  
  <p>and got an error:</p>
  
  <p><code>Could not find gem 'spring (&gt;= 0) ruby' in the gems available on this machine.
  Run</code>bundle install<code>to install missing gems.</code></p>
  
  <p>And after following the instructions, I got </p>
  
  <pre><code>'An error occurred while installing pg (0.17.1), and Bundler cannot continue.
  Make sure that `gem install pg -v '0.17.1'` succeeds before bundling.'
  </code></pre>
  
  <p>And then...</p>
  
  <pre><code>ERROR:  Error installing pg:
      ERROR: Failed to build gem native extension.
  
          ...
  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.
  </code></pre>
  
  <p>A similar SO question said the problem was solved by updating XCode, but I don't think that's my problem.  If it wasn't already apparent, I'm not very experienced with the terminal or ruby, so I'm not sure how I can approach this issue.</p>
  
  <p>EDIT:</p>
  
  <p>new error message</p>
  
  <pre><code>Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
  
      /Users/mahireusufzai/.rbenv/versions/2.1.1/bin/ruby extconf.rb 
  checking for pg_config... yes
  Using config values from /usr/local/bin/pg_config
  *** 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.
  </code></pre>
  
  <p>...</p>
  
  <pre><code>/Users/mahireusufzai/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
  You have to install development tools first.
      from /Users/mahireusufzai/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:541:in `try_link0'
      from /Users/mahireusufzai/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:556:in `try_link'
      from extconf.rb:39:in `&lt;main&gt;'
  
  extconf failed, exit code 1
  
  Gem files will remain installed in /Users/mahireusufzai/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/pg-0.17.1 for inspection.
  </code></pre>