0

I have been trying to run bundle install and I get the following error:

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /Users/fr/.rvm/rubies/ruby-2.0.0-p247/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 ***

Upon following the instructions, I received the following error:

gem install pg -v '0.17.0'                                                    ⏎
Building native extensions.  This could take a while...
ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

    /Users/fr/.rvm/rubies/ruby-2.0.0-p247/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 ***

I followed the instructions provided in a similar issue reported earlier. Please see Installing PG gem - failure to build native extension

But this has not helped as shown below:

brew install postgresql
Warning: Could not link postgresql. Unlinking...
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
You can try again using `brew link postgresql'

Possible conflicting files are:
==> /usr/local/Cellar/postgresql/9.3.4/bin/initdb /usr/local/var/postgres
==> Summary
  /usr/local/Cellar/postgresql/9.3.4: 2928 files, 38M


brew link postgresql
Linking /usr/local/Cellar/postgresql/9.3.4...
Warning: Could not link postgresql. Unlinking...
Error: Could not symlink file: /usr/local/Cellar/postgresql/9.3.4/share/man/man7/WITH.7
/usr/local/share/man/man7 is not writable. You should change its permissions.

My two concerns are:

  1. How can I fix the issue related to the 'pg' gem?
  2. To fix this issue, is it necessary to modify the read-write permissions of the files mentioned for the brew link postgresql output?
Community
  • 1
  • 1
fr_muses
  • 1,475
  • 2
  • 10
  • 10
  • 1
    Has been answered multiple times before: http://stackoverflow.com/questions/13086073/rails-install-pg-cant-find-the-libpq-fe-h-header http://stackoverflow.com/questions/6040583/cant-find-the-libpq-fe-h-header-when-trying-to-install-pg-gem – SreekanthGS Apr 07 '14 at 07:59
  • please check the link http://stackoverflow.com/a/18864397/2518860 – Bachan Smruty Apr 07 '14 at 08:03
  • Check the permissions: `ls -ld /usr/local/Cellar` and open them up for writing: `sudo chmod a+w /usr/local/Cellar` and try install again `brew install postgresql` – Roman Kiselenko Apr 07 '14 at 09:06
  • Hi @Monk_Code, I tried your suggestion. Upon checking the directory, I saw the below output: `ls -ld /usr/local/Cellar drwxrwxrwx 21 fr wheel 714 Apr 7 10:49 /usr/local/Cellar` Upon trying `brew install postgresql`, I saw the below output: `Linking /usr/local/Cellar/postgresql/9.3.4... Warning: Could not link postgresql. Unlinking... Error: Could not symlink file: /usr/local/Cellar/postgresql/9.3.4/share/man/man7/WITH.7 /usr/local/share/man/man7 is not writable. You should change its permissions.` – fr_muses Apr 08 '14 at 04:50
  • Hi Everyone, I managed to get the issue solved. The main issue was the pg version - 0.17.0. I installed the latest Postgres.app and verified the version was 0.17.1 upon installation. I then modified the gem file to simply `gem 'pg'` and ran `bundle update`. Thanks to everyone for the suggestions and links. – fr_muses Apr 08 '14 at 05:19

1 Answers1

0

I managed to get the issue solved. The main issue was the pg version - 0.17.0. I installed the latest Postgres.app and verified the version was 0.17.1 upon installation. I then modified the gem file to simply gem 'pg' and ran bundle update. Thanks to everyone for the suggestions and links.

fr_muses
  • 1,475
  • 2
  • 10
  • 10