title: Unable to install pg gem on MAC
body: <p>I have been trying to install pg gem using, <code>gem install pg</code>, and its showing me an error.</p>
  
  <p>Then I tried <code>brew install postgresql</code>, which, in the end showed error stating use/local/bin already exixts. If I am directly running <code>bundle install</code> in the app folder, its showing the error on installing pg 0.18.4, stating permission denied @ rb_sysopen.</p>
  
  <p>The errors that I am getting:</p>
  
  <pre><code>Amans-MacBook-Air:~ aman$ gem install pg
  ERROR: While executing gem ... (Errno::EACCES)
  Permission denied @ rb_sysopen - /Users/aman/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/pg-0.18.4/.gemtest
  
  Amans-MacBook-Air:~ aman$ brew install postgresql
  Warning: postgresql-9.5.3 already installed, it's just not linked
  
  Amans-MacBook-Air:~ aman$ brew link postgresql
  Linking /usr/local/Cellar/postgresql/9.5.3... Error: File exists - /usr/local/lib
  </code></pre>
  
  <p>What should I do, any suggestions!</p>