Search code examples
ruby-on-railsrubypostgresqlgemfilepg

Bundle install for 'pg' gem endless errors


So I'm at the stage of a project where I need to add the 'pg' gem for rails before I can deploy to Heroku, and of course I keep getting error after error. When I first did your basic bundle install I got the errors:

ERROR: Error installing pg: ERROR: Failed to build gem native extension.

Can't find the 'libpq-fe.h header * extconf.rb failed *

An error occurred while installing pg (0.21.0), and Bundler cannot continue. Make sure that gem install pg -v '0.21.0' succeeds before bundling.

If I try as it suggests with the last sentence, it just repeats the same set of errors.

Hoping there is a simple fix so I can move forward to my next error! Any and all suggestions are appreciated from this newbie developer.


Solution

  • I think you can find the answer here: Can't install pg gem on Rails

    You should probably install the PostgreSQL development libraries.

    If you're on Ubuntu this will help:

    sudo apt-get install libpq-dev

    On a Mac:

    brew install postgresql