dipakp.rails dipakp.rails - 3 months ago 14
Linux Question

PG + extconf failed, exit code 1 in Linux

I am getting error in installing PG in Linux (CentOS) System.


gem install pg


Then I'm getting following error

Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.

current directory: /usr/local/rvm/gems/ruby-2.3.0/gems/pg-0.18.4/ext
/usr/local/rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160831-5454-1endyls.rb extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/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.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/local/rvm/rubies/ruby-2.3.0/bin/$(RUBY_BASE_NAME)
--with-pg
--without-pg
--enable-windows-cross
--disable-windows-cross
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib

To see why this extension failed to compile, please check the mkmf.log which can be found here:

/usr/local/rvm/gems/ruby-2.3.0/extensions/x86_64-linux/2.3.0/pg-0.18.4/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /usr/local/rvm/gems/ruby-2.3.0/gems/pg-0.18.4 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.3.0/extensions/x86_64-linux/2.3.0/pg-0.18.4/gem_make.out


and for solution I try many things and installed required packages but still getting same error. you can see my logs for postgres*

After run


yum list postgres*


Loaded plugins: priorities, update-motd, upgrade-helper
24 packages excluded due to repository priority protections
Installed Packages
postgresql92.x86_64 9.2.15-1.57.amzn1 @amzn-main
postgresql92-contrib.x86_64 9.2.15-1.57.amzn1 @amzn-main
postgresql92-devel.x86_64 9.2.15-1.57.amzn1 @amzn-main
postgresql92-libs.x86_64 9.2.15-1.57.amzn1 @amzn-main
postgresql92-server.x86_64 9.2.15-1.57.amzn1 @amzn-main
postgresql92-server-compat.x86_64 9.2.15-1.57.amzn1 @amzn-main
postgresql93.x86_64 9.3.11-1.61.amzn1 @amzn-main
postgresql93-contrib.x86_64 9.3.11-1.61.amzn1 @amzn-main
postgresql93-devel.x86_64 9.3.11-1.61.amzn1 @amzn-main
postgresql93-libs.x86_64 9.3.11-1.61.amzn1 @amzn-main
postgresql93-server.x86_64 9.3.11-1.61.amzn1 @amzn-main
postgresql94.x86_64 9.4.6-1.66.amzn1 @amzn-main
postgresql94-libs.x86_64 9.4.6-1.66.amzn1 @amzn-main
Available Packages
postgresql-jdbc.noarch 8.4.701-8.11.amzn1 amzn-main
postgresql-jdbc-javadoc.noarch 9.4.1208-1.rhel6 pgdg92
postgresql-odbc.x86_64 08.04.0200-1.6.amzn1 amzn-main
postgresql8.x86_64 8.4.20-5.52.amzn1 amzn-updates
postgresql8-contrib.x86_64 8.4.20-5.52.amzn1 amzn-updates
postgresql8-devel.x86_64 8.4.20-5.52.amzn1 amzn-updates
postgresql8-docs.x86_64 8.4.20-5.52.amzn1 amzn-updates
postgresql8-libs.i686 8.4.20-5.52.amzn1 amzn-updates
postgresql8-libs.x86_64 8.4.20-5.52.amzn1 amzn-updates
postgresql8-plperl.x86_64 8.4.20-5.52.amzn1 amzn-updates
postgresql8-plpython.x86_64 8.4.20-5.52.amzn1 amzn-updates
postgresql8-pltcl.x86_64 8.4.20-5.52.amzn1 amzn-updates
postgresql8-server.x86_64 8.4.20-5.52.amzn1 amzn-updates
postgresql8-test.x86_64 8.4.20-5.52.amzn1 amzn-updates
postgresql92-debuginfo.x86_64 9.2.18-1PGDG.rhel6 pgdg92
postgresql92-docs.x86_64 9.2.15-1.57.amzn1 amzn-main
postgresql92-libs.i686 9.2.15-1.57.amzn1 amzn-main
postgresql92-odbc.x86_64 09.05.0400-1PGDG.rhel6 pgdg92
postgresql92-plperl.x86_64 9.2.15-1.57.amzn1 amzn-main
postgresql92-plpython.x86_64 9.2.18-1PGDG.rhel6 pgdg92
postgresql92-plpython26.x86_64 9.2.15-1.57.amzn1 amzn-main
postgresql92-plpython27.x86_64 9.2.15-1.57.amzn1 amzn-main
postgresql92-pltcl.x86_64 9.2.15-1.57.amzn1 amzn-main
postgresql92-python.x86_64 4.2-1PGDG.rhel6 pgdg92
postgresql92-python-debuginfo.x86_64 4.2-1PGDG.rhel6 pgdg92
postgresql92-tcl.x86_64 2.1.1-1.rhel6 pgdg92
postgresql92-tcl-debuginfo.x86_64 2.1.1-1.rhel6 pgdg92
postgresql92-test.x86_64 9.2.15-1.57.amzn1 amzn-main
postgresql93-docs.x86_64 9.3.11-1.61.amzn1 amzn-main
postgresql93-libs.i686 9.3.11-1.61.amzn1 amzn-main
postgresql93-plperl.x86_64 9.3.11-1.61.amzn1 amzn-main
postgresql93-plpython26.x86_64 9.3.11-1.61.amzn1 amzn-main
postgresql93-plpython27.x86_64 9.3.11-1.61.amzn1 amzn-main
postgresql93-pltcl.x86_64 9.3.11-1.61.amzn1 amzn-main
postgresql93-test.x86_64 9.3.11-1.61.amzn1 amzn-main
postgresql94-contrib.x86_64 9.4.6-1.66.amzn1 amzn-main
postgresql94-devel.x86_64 9.4.6-1.66.amzn1 amzn-main
postgresql94-docs.x86_64 9.4.6-1.66.amzn1 amzn-main
postgresql94-libs.i686 9.4.6-1.66.amzn1 amzn-main
postgresql94-plperl.x86_64 9.4.6-1.66.amzn1 amzn-main
postgresql94-plpython26.x86_64 9.4.6-1.66.amzn1 amzn-main
postgresql94-plpython27.x86_64 9.4.6-1.66.amzn1 amzn-main
postgresql94-server.x86_64 9.4.6-1.66.amzn1 amzn-main
postgresql94-test.x86_64 9.4.6-1.66.amzn1 amzn-main
postgresql_autodoc.noarch 1.41-1.rhel6 pgdg92


Unable to install pg. Please help me.

I installed


yum install postgresql92-server



Loaded plugins: priorities, update-motd, upgrade-helper
amzn-main/latest | 2.1 kB 00:00
amzn-updates/latest | 2.3 kB 00:00
24 packages excluded due to repository priority protections
Package postgresql92-server-9.2.15-1.57.amzn1.x86_64 already installed and latest version
Nothing to do

Answer

it seems you have to install postgres header files and libraries. as your system is RHEL try this.

yum install postgresql-devel

if you are using postgres 9.4 then,

yum install postgresql94-devel

then rerun gem install pg 'version'