Skip to content

Instantly share code, notes, and snippets.

@hoanghiep90
Created May 24, 2015 20:04
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hoanghiep90/e3f84de652e28b0d8496 to your computer and use it in GitHub Desktop.
Save hoanghiep90/e3f84de652e28b0d8496 to your computer and use it in GitHub Desktop.
Can’t find the ‘libpq-fe.h header
I need to install pg 0.17.1 gem on a server running CentOS. This is the error message I saw:
# gem install pg -v '0.17.1'
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/usr/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 ***
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.
...
First thing came to my mind is that, I must have forgotten to install the -dev package.
# yum install postgresql93-devel
Then, when I ran gem command again, suprisingly I still got the same error message. So I checked the explanation in the error message carefully.
# locate pg_config
/usr/pgsql-9.3/bin/pg_config
/usr/pgsql-9.3/share/man/man1/pg_config.1
# gem install pg -v '0.17.1' -- --with-pg-config=/usr/pgsql-9.3/bin/pg_config
This time, pg gem was successfully installed.
Note, if you use bundle to install gem, you’ll need to run this command:
# bundle config build.pg --with-pg-config=/usr/pgsql-9.3/bin/pg_config
# bundle install --path vendor/bundle
@deptz
Copy link

deptz commented Mar 31, 2020

thank you for sharing this!

@lhchanh
Copy link

lhchanh commented Mar 31, 2020

Thanks for sharing <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment