cannot install required gem "pg" on cPanel

furquan

Well-Known Member
Jul 27, 2002
473
4
168
Hello All,

I am trying to install a gem by the name of"pg" on my cPanel server.

I have tried installing it via WHM and SSH and users cPanel interface, but in vein.

Every time I try I get this following error :-

Fetching: pg-0.13.2.gem ( 88%)
Fetching: pg-0.13.2.gem ( 91%)
Fetching: pg-0.13.2.gem ( 93%)
Fetching: pg-0.13.2.gem ( 95%)
Fetching: pg-0.13.2.gem ( 98%)
Fetching: pg-0.13.2.gem (100%)
Fetching: pg-0.13.2.gem (100%)
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.
Etc.
Etc.
Can any one on board assist me with this ?

Thank you,
 

furquan

Well-Known Member
Jul 27, 2002
473
4
168
Hello ,

The message that I have pasted above is what I see when I run "gem install pg" from command line :(
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
Do you have PostgreSQL installed by using "/usr/local/cpanel/scripts/installpostgres" on the machine? You have to have PostgreSQL installed in order to install anything that requires it. I didn't have PostgreSQL installed and I was unable to install pg. After I installed it, it was still failing so I had to revert my Ruby installation and reinstall it for some reason. After I did, I checked that the postgresql rpms existed and then was able to install it:

Code:
[email protected] [~]# rpm -qa | grep -i postgres
postgresql-devel-8.4.9-1.el6_1.1.i686
postgresql-libs-8.4.9-1.el6_1.1.i686
postgresql-server-8.4.9-1.el6_1.1.i686
postgresql-8.4.9-1.el6_1.1.i686
Code:
[email protected] [~]# gem install pg
Fetching: pg-0.13.2.gem (100%)
Building native extensions.  This could take a while...
Successfully installed pg-0.13.2
1 gem installed
Installing ri documentation for pg-0.13.2...

Enclosing class/module 'rb_mPG' for class Connection not known

Enclosing class/module 'rb_mPG' for class Result not known
Installing RDoc documentation for pg-0.13.2...

Enclosing class/module 'rb_mPG' for class Connection not known

Enclosing class/module 'rb_mPG' for class Result not known
The ri and RDoc failures are simply documentation warnings. They would be harmless warnings. The module does successfully install.

Of note, if you have a failure like existed, you'd normally want to search online for the error message where you'll find mention of the postgresql-devel headers being required for the component. When you haven't installed PostgreSQL using cPanel, you won't have the rpm that is needed, which causes the failure.
 

furquan

Well-Known Member
Jul 27, 2002
473
4
168
Hello All !

I finally manged to get this solved, But not with out the help of cPanels wonderful staff "Tracey Clark" :)

First, had to check the logs located at :-

/usr/lib/ruby/gems/1.8/gems/pg-0.13.2/ext/mkmf.log

This is what we see :-

/tmp/cc0l3StH.o: In function `t':
conftest.c:(.text+0x17): undefined reference to `PQconnectionUsedPassword'
collect2: ld returned 1 exit status
checked program was:
/* begin */
1: /*top*/
2: int main() { return 0; }
3: int t() { PQconnectionUsedPassword(); return 0; }
/* end */
As the original output suggests, We were receiving this error because the system is missing a dependency of the gem. If we do a web search on "undefined reference to `PQconnectionUsedPassword'" we will find more information about this error. We can work around this error by telling gem to also include dependencies with:


# gem install pg --include-dependencies
It still runs into a problem with PostgreSQL being too old to support the version of this gem that we had specified.
checking for PQconnectionUsedPassword()... no
Your PostgreSQL is too old. Either install an older version of this gem or upgrade your database.
We had to go though this url to upgrade our version of PostgreSQL :


Installing or Updating PostgreSQL on Your cPanel & WHM Server


Hope this helps some one :)