0

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.

Tab Codes
  • 33
  • 5
  • 2
    Possible duplicate of [Can't find the 'libpq-fe.h header when trying to install pg gem](https://stackoverflow.com/questions/6040583/cant-find-the-libpq-fe-h-header-when-trying-to-install-pg-gem) – Gerry Apr 20 '18 at 13:41

1 Answers1

0

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

Patrick Barattin
  • 617
  • 6
  • 18
  • Thanks Patrick for your suggestions. When I tried “brew install postgresql” it tells me it is already installed and just not linked. When I tried “brew link postgresql” just now it says: Error: could not symlink share/man/man3/SPI_connect.3/usr/local/share/man/man3 is not writable. Which leaves me in a state of staring at me screen. – Tab Codes Apr 20 '18 at 14:08
  • Try this: `sudo chown -R \`whoami\` /usr/local/share/man/ ` end then again: `brew link postgresql` – Patrick Barattin Apr 21 '18 at 14:14
  • Hey Patrick, I sincerely thank you for passing that info to me. It worked! Since I am still an underling on here, I can’t vote for it. Hopefully someone else with cred reading this can do it for me. Much appreciated – Tab Codes Apr 25 '18 at 08:27